Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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]
like image 922
Mobile Man Avatar asked Mar 13 '15 01:03

Mobile Man


People also ask

Why is node-Gyp not working on my Mac OS?

This issue is usually caused because a node-gyp config file called common.gypi is not set up for your current Mac OS version. It often times comes accompanied with an error message like:

What version of python do I need for node Gyp?

You’ll have to run this command: npm config set msvs_version 2015 –global 5. Make sure you have Python 2.7 installed. Next up is to download Python 2.7. This is important–by default, you’ll install the newest version (3.x.x), but only 2.7 is compatible with node-gyp.

How do I get node-Gyp to work with npm?

To do that, run this command: npm config set python python2.7 If you followed the last few steps, you should now have everything necessary to get node-gyp working. Make sure you’ve restarted your terminal and are running it as an administrator, and try doing your install again.

How to install NPM on Xcode?

Now, install the Xcode by running this command. This command prompts with a popup, click on the install button and proceed with the installation. It takes some time to download and install the Xcode command-line tools. Once you are successfully installed, you can now download new npm packages without any (gyp) error messages.


2 Answers

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

like image 197
Brian Vanderbusch Avatar answered Oct 18 '22 09:10

Brian Vanderbusch


/bin/sh: pkg-config: command not found, you need to install pkg-config

run following command to install it: $brew install pkg-config. after that, run npm install again. $npm install zmq

like image 33
Shrek Avatar answered Oct 18 '22 09:10

Shrek