Reputation: 1419
I'm trying to install a node.js module (zmq in this case) with npm install. The C lib needed for this module is not installed in a standard location. How do I specify extra include paths and lib paths to npm? I've tried things like "CFLAGS="-I/path/to/include" npm install" with no effect.
Upvotes: 4
Views: 5670
Reputation: 1
Another solution (does not require any file changes) is to use pkg-config's PKG_CONFIG_PATH
variable, which should point to the location where the libraries are installed. If zmq has been installed at /opt/zmq
then PKG_CONFIG_PATH=/opt/zmq/lib/pkgconfig pkg-config libzmq --libs
should return -L/opt/zmq/lib -lzmq
and npm install
can be run with
PKG_CONFIG_PATH=/opt/zmq/lib/pkgconfig npm install
Before node app is started LD_LIBRARY_PATH
must be set accordingly, i.e: LD_LIBRARY_PATH=/opt/zmq/lib node app.js
Upvotes: 0
Reputation: 2694
The zeromq module can be built as follows (other modules may work the same):
/tmp/zeromq.node-master
binding.gyp
file-I
and library -L
paths there. e.g.
['OS=="linux"', {
'cflags': [
'<!(pkg-config libzmq --cflags 2>/dev/null || echo "")',
'-I/usr/local/zeromq3/include'
],
'libraries': [
'<!(pkg-config libzmq --libs 2>/dev/null || echo "")',
'-L/usr/local/zeromq3/lib'
],
}],
npm install /tmp/zeromq.node-master
Upvotes: 4