node-gyp 'pkg-config: command not found' on mac 10.5.8 during npm install

Mobile Man picture Mobile Man · Mar 13, 2015 · Viewed 16k times · Source

Trying to do an npm install on mac-osx of github project. Don't see pkg-config in packages.json why would node-gyp expect this? It seems like the node-gyp should have incldued pkg-config. I thought this is the way node works. Install a package and it pulls in whatever it needs. I guess this is different somehow. Also wondering which version pkg-config its looking for.

And yes, I've been out there and downloaded the tarball but its installation instructions for mac really are nonesense. it stays ./configure then make install. But there makefile is not available and everything is at same directory level yet it says cd into code directory etc.

> node-gyp rebuild

/bin/sh: pkg-config: command not found
gyp: Call to 'pkg-config libzmq --libs' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 12.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Mac1/Downloads/projdirectory/node_modules/zmq
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected]

Answer

Brian Vanderbusch picture Brian Vanderbusch · Apr 4, 2015

This has nothing to do with a pkg-config npm module. This is a build failure of the zmq module. the /bin/sh: bit is telling you that it's trying to run an actual command on your shell, which in this case, would be a the pkg-config script, probably found in your /usr/local/include/zmq or /opt/local/include/zmq folder.

The reason pkg-config is not found, is because ZMQ is not a native node module, and you have to make sure you've downloaded and installed ZMQ before running the npm install you're trying to run.

In this case, you're trying to install zmq or one of it's libs, which all require the ZMQ product to be installed on your system.

Whenever you see node-gyp in a failed npm install, it's a good clue that what you're trying to install is a node wrapper for another tool native to your OS.

EDIT: After looking at the latest install of zmq, there is not pkg-config folder, rather... there's a pkgconfig folder.

There is a bug reported for this, but that alone is not going to solve the OP problem. If you're using homebrew, you can first run

brew install zeromq
brew install pkgconfig

And then run your npm install (whatever zmq lib you were installing)

Otherwise, you'll have to do some work to rebuild your zmq from source and prefix the installation onto your $PATH