node-gyp downloads following files from the Internet during installation and building of the native modules like iconv, ref, ffi, etc:
https://nodejs.org/download/release/v6.10.0/node-v6.10.0-headers.tar.gz
https://nodejs.org/download/release/v6.10.0/win-x86/node.lib
https://nodejs.org/download/release/v6.10.0/win-x64/node.lib
https://nodejs.org/download/release/v6.10.0/SHASUMS256.txt
How to make node-gyp to use these files from local folders, not from the Internet?
I've found the following solution:
1. Download https://nodejs.org/download/release/v6.10.0/node-v6.10.0-headers.tar.gz
2. Unpack it to some local folder.
3. Create folder Release in this local folder.
4. Download file https://nodejs.org/dist/v6.10.0/win-x64/node.lib into the folder Release.
5. Set property nodedir in .npmrc which will point to the folder with unpacked headers:
nodedir=D:\tools\node_src\node-v6.10.0-headers
Now npm installs packages and node-gyp builds native packages without downloading node headers and libs from the Internet.
Is it a correct approach?
I cannot find in the documentation that I should download node.lib and put it to the Release directory.
I decided to do it after analyzing the traces of node-gyp and code of node-gyp.
Is it possible to setup the location of node.lib using some npm_config_xxx property?
node-gyp is a cross-platform command-line tool written in Node. js for compiling native addon modules for Node. js. It contains a vendored copy of the gyp-next project that was previously used by the Chromium team, extended to support the development of Node.
gyp file describes the configuration to build your module, in a JSON-like format. This file gets placed in the root of your package, alongside package. json .
node-gyp folder is the devDir of node-gyp (see relevant source code). This is where development header files are copied in order to perform the compilation of native modules. you can safely delete this directory, as it will be re-created the next time you'll install a module that needs node-gyp .
Below works for me:
# download for private repo, probably you're behind firewall curl -k -o node-v8.9.4-headers.tar.gz -L https://nexus.com/repository/binaries/node/v8.9.4/node-v8.9.4-headers.tar.gz # capture the absolute path TARBALL_PATH=$(pwd) # configure tarball in npm config npm config set tarball ${TARBALL_PATH}/node-v8.9.4-headers.tar.gz # The below command should pass without gyp error npm install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With