Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
mullr opened this Issue · 4 comments

4 participants

@mullr

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

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

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.

@jaseemabid

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

@domenic
Collaborator

Dupe of #1573.

@domenic domenic closed this
@springmeyer springmeyer referenced this issue in mapbox/node-pre-gyp
Closed

npm link #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.