'How to tell node-gyp / node-sass that I already have my node-headers?
I'm currently working behind a proxy that doesn't allow me the HTTP GET request stage of this command:
node node-sass/scripts/build.js
Request stage:
gyp http GET https://nodejs.org/download/release/v10.8.0/node-v10.8.0-headers.tar.gz gyp WARN install got an error, rolling back install
As said, I downloaded those headers (and particularly the mentioned-in-the-log tarball) locally. How do I tell node-sass that I do have my file locally? I tried looking in build.js directly, but I couldn't manage to do what I want ; that might be out of my level.
Solution 1:[1]
OK so I managed to do it. I simply had to unpack the tarball, and make point a nodedir config in my .yarnrc to the folder created by unpacking.
So:
tar -xzvf your_headers_package yarn config set nodedir your_headers_folder
And that worked for me. I feel... pretty dumb now.
Solution 2:[2]
For those trying to set up node-gyp with no internet access:
- 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
installVersionmanually:echo 9 >~/.node-gyp/6.10.1/installVersion(usually it is created automatically if you have internet access)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | V. Courtois |
| Solution 2 | mel3kings |
