1

node-gyp has millions of threads regarding offline installation issues, however, none of the solutions worked for me.
I'm trying to install node-sass-chokidar actually, which depends on node-sass and therefore depends on this package. I'm working on Ubuntu 16.04.
Due to the pc being offline, I cannot put the full log, however, in short:

...
gyp info using [email protected] | linux | x64
...
gyp verb get node dir no --target version specified, falling back to hot node version: 8.9.4
...
gyp verb install version is no good; reinstalling
gyp verb ensuring nodedir is created /home/user/.node-gyp/8.9.4
gyp http GET https://node.js.org/download/release/v.8.9.4/node-v8.9.4-headers.tar.gz
...
gyp ERR! stack Error: This is most likely not a problem with node-gyp or the package itself and
gyp ERR! stack is related to network connectivity. In most cases you are behind a proxy...
...

I've manually downloaded the above headers files, but I can't seem to be able to use them.
I tried to extract the headers and then yarn add node-sass-chokidar --nodedir /path/to/headers, but without success.
I also tried with the exact path of the headers (they are nested inside the downloaded directories inside include/node/....
Another thing I attempted was to put the headers in $HOME/.node-gyp/8.9.4, which failed as well.

I wonder if I need to download the whole node source for the --nodedir path, however, I don't think its reasonable to do such thing for a minor sass builder library... it just feels crazy.
What am I doing wrong? No matter what I do the library tries to access the internet and fails to use the headers I downloaded.

2 Answers 2

2

I had the same issue trying to setup an Ubuntu server with no internet access due to firewall restrictions. node-gyp for some reason tries to look for node-headers under their local cache and if there is no internet access it automatically fails. Here's what I've done:

To setup node headers for node-gyp:

  • Get the node headers file: curl -O https://nodejs.org/dist/v14.17.3/node-v14.17.3-headers.tar.gz (make sure you have the correct node version appropriate, and you need a machine with internet)
  • Copy header tarball to offline machine (approach may vary depending on your situation an example may be to winscp to vm)
  • Create the node-gyp folder that the library looks for if it's not already existing: mkdir -p ~/.cache/node-gyp/14.17.3 (PITFALL: in some versions node-gyp folder is under ~/.node-gyp)
  • tar the file to node-gyp folder: tar -xf node-v14.17.3-headers.tar.gz --directory ~/.cache/.node-gyp/6.10.1/ --strip-components 1 (make sure you have the correct versions here)
  • create the installVersion manually: echo 9 >~/.node-gyp/6.10.1/installVersion (usually it is created automatically if you have internet access)
Sign up to request clarification or add additional context in comments.

1 Comment

This has to be done for any specific gyp version, correct? Is there any generic way?
1

Sad truth was that I missed the installVersion file which wasn't present in the headers download.
Once I extracted the headers to ~/.node-gyp and added an installVersion file containing 9, the installation worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.