How to prevent node -gyp from downloading node -headers.tar.gz and node.lib from the Internet?

node -gyp downloads the following files from the Internet during the installation and creation of its own modules, such as 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 use these files from local folders and not from the Internet?

I found the following solution:
1. Download https://nodejs.org/download/release/v6.10.0/node-v6.10.0-headers.tar.gz
2. Unzip it to a local folder.
3. Create the Release folder in this local folder.
4. Download the file https://nodejs.org/dist/v6.10.0/win-x64/node.lib to the Release folder.
5. Set the nodedir property to .npmrc, which will point to the folder with the unpacked headers:
nodedir = D: \ tools \ node_src \ node -v6.10.0-headers

Now npm installs packages and node -gyp creates its own packages without downloading node headers and libraries from the Internet.
Is this the right approach?

I cannot find in the documentation that I have to download node.lib and put it in the Release directory.
I decided to do this after analyzing the traces of node -gyp and the node -gyp code.
Is it possible to set the location of node.lib using some npm_config_xxx property?

+11
source share
1 answer

As shown here, you can use the -tarball option for node -gyp https://github.com/nodejs/node-gyp/issues/1133

0
source

Source: https://habr.com/ru/post/1265302/


All Articles