If the node module is written in C and I install it on a Mac, do I need to reinstall it for deployment on Linux?

I often hear from experienced node developers that checking in node_modules is good practice. But most developers write on Mac / Darwin x64, but deploy on Linux x64.

If the node module is written in C, and I install it on OS X, does it need to be rebuilt in Linux?

0
npm deployment
Jun 11 '14 at 9:25
source share
2 answers

Answer: package dependent

  • Most packages require reinstallation, as the node gyp compiler does not cross-compile by default - thanks to @tkone.

  • Some packages, such as node-sass , dynamically load ready-made binaries for the corresponding platform (previously, node-sass used to include binaries for all platforms, however this has changed recently).

+1
Jun 11 '14 at 9:31 on
source share

Currently, the current node-sass 3.4.2 does not contain binaries in the originally downloaded npm package (as shown in the npm package cache in ~/.npm ).

What he does is that his install.js script will download the binary for the platform and save it under vendor/{platform}-{arch}-{process.versions.module}.node . After installation, the install.js script is usually not called again by npm.

Therefore, when you go into node_modules , it will contain a binary file only for your initial platform.

For fun, I moved the downloaded binary, which should be the same as someone else checking your node_modules on a different platform. When this is done, node-sass is smart enough to detect that the required binary does not exist. It exits gracefully, recommending running npm rebuild node-sass (also hinting that this is usually necessary when changing the version of node). This will download the binary for the current platform, and then everything will be fine.

However, which is completely specific for node-sass, other packages with binary files may behave completely differently.

(see Node.js version release for an explanation of process.versions.modules aka. NODE_MODULES_VERSION, which defines the last number in a binary URL load. The binary name is built in function getBinaryName() in ~ / .npm / node-sass / {version} / package.tgz / lib / extension.js)

0
Feb 23 '16 at 21:14
source share



All Articles