No internet connection or limited. npm install
will access npmjs to install node modules, any native modules will attempt to load the native modules that have been pre-built. This is defined the relavent package author's in each module's package.json.
However if there is no prebuilt binary available either because ones not defined, or the connection can not be established it will be rebuilt. This itself though will access the internet to get the node headers.
If you can, but sometimes not practical or possible
Again if you can but sometimes not practical or possible
Either using something live Verdaccio or other enterprise NPMJS repository. In your application or module, add a .npmrc
file with
registry=http://localhost:4873
Check npm docs for more information about other options that can be specified here.
The code will be rebuilt, but you need the headers. For the version of node that will build the code, goto ttps://nodejs.org/dist/ and find the version you are using. Then find the file with 'headers' in it. eg for Node 8.17.0 the full path is https://nodejs.org/dist/v8.17.0/node-v8.17.0-headers.tar.gz
Put this in the root of your module, and it must be included in the final package if you publish it.
In the pacakge.json add this line (here the downloaded file has been renamed to headers.tgz. you are at liberty to change this if you want.
"dist-url": "headers.tgz"
With a locally cached copy of the node modules, and with the headers matching your node version, the native code will be rebuilt. This means no interent access required (apart from to get the code cached initially). Note that installation will take longer than normal as the code is being rebuilt.
Also do warranty that this will work reliably, see points 0 and 1 above for a solution.