`npm link` shouldn't call `node-gyp rebuild` #2788

Closed
mullr opened this Issue Sep 6, 2012 · 4 comments

Comments

Projects
None yet
4 participants

mullr commented Sep 6, 2012

If you install a native package globally, (for example npm install -g sqlite3), it builds the native libraries right away, which makes sense. But then when you link to that globally installed package from some other package (npm link sqlite3), it runs node-gyp rebuild again.

If it didn't do this, npm link this could be a reasonable way to share a single build of a binary module between different packages without having to recompile it for each one.

mullr commented Sep 6, 2012

Another interesting side effect of this: try running npm link sqlite3 in an empty directory, on a system without sqlite3 installed globablly. It builds it twice!

> sqlite3@2.1.5 install /usr/local/lib/node_modules/sqlite3
> node-gyp rebuild

  CC(target) Release/obj.target/sqlite3/deps/sqlite3/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.node
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
  CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
  CXX(target) Release/obj.target/node_sqlite3/src/statement.o
  SOLINK_MODULE(target) Release/node_sqlite3.node
  SOLINK_MODULE(target) Release/node_sqlite3.node: Finished
sqlite3@2.1.5 ../../../../../../../../usr/local/lib/node_modules/sqlite3

> sqlite3@2.1.5 install /Users/mullr/<snip>/node_modules/sqlite3
> node-gyp rebuild

  CC(target) Release/obj.target/sqlite3/deps/sqlite3/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.node
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
  CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
  CXX(target) Release/obj.target/node_sqlite3/src/statement.o
  SOLINK_MODULE(target) Release/node_sqlite3.node
  SOLINK_MODULE(target) Release/node_sqlite3.node: Finished
/Users/mullr/devel/<snip>/node_modules/sqlite3 -> ../../../../../../../../usr/local/lib/node_modules/sqlite3 -> /usr/local/lib/node_modules/sqlite3

jspiro commented Feb 21, 2013

Any workarounds? This has been driving me crazy. My small in-development node module is rebuild six times; fortunately it builds fairly quickly...

The Makefile generated by node-gyp configure does the right thing by not rebuilding when it shouldn't, but of course Makefiles are only human conveniences -- npm link and node-gyp completely ignore the fact that you generated it and rebuild every time.

Affects me too. My project is being rebuilt again and again on npm link.

Member

domenic commented Jun 18, 2013

Dupe of #1573.

domenic closed this Jun 18, 2013

springmeyer referenced this issue in mapbox/node-pre-gyp Feb 25, 2014

Closed

npm link #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment