profile
viewpoint

Ask questionsnode-gyp always pulls headers from internet

After tracing through the code, I noticed that no matter what unless the --tarball flag is explicitly stated node-gyp will always attempt to pull the headers from the internet. The problem with this workaround is that if you try to install an existing npm module built with node-gyp, there is no means to specifying this flag.

It looks like fixing this would be as simple as adding a check if the file already exists in ~/.node-gyp for the architecture, or supporting an environment variable that specifies the path rather than a flag:

https://github.com/nodejs/node-gyp/blob/f6eab1f9e4b160b60b2736bb01a09c83785ba979/lib/install.js

nodejs/node-gyp

Answer questions nickboldt

Seeing this in a firewalled build:

yarn install v1.17.3
 $ node-gyp install
 gyp info it worked if it ends with ok
 gyp info using node-gyp@3.8.0
 gyp info using node@10.14.1 | linux | x64
 gyp http GET https://nodejs.org/download/release/v10.14.1/node-v10.14.1-headers.tar.gz
 gyp WARN install got an error, rolling back install
 gyp ERR! install error
 gyp ERR! stack Error: connect ECONNREFUSED 104.20.23.46:443
 gyp ERR! stack     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
 gyp ERR! System Linux 3.10.0-957.21.2.el7.x86_64
 gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "install"
 gyp ERR! cwd /home/theia-dev/theia-source-code
 gyp ERR! node -v v10.14.1
 gyp ERR! node-gyp -v v3.8.0
 gyp ERR! not ok

I can confirm that this works to prevent node-gyp from trying to download the headers:

NODE_VER=v10.14.1
curl -sSL https://nodejs.org/download/release/${NODE_VER}/node-${NODE_VER}-headers.tar.gz \
        -o /tmp/node-headers.tgz; \
npm config set tarball /tmp/node-headers.tgz

Now:

 yarn install v1.17.3
 $ node-gyp install
 gyp info it worked if it ends with ok
 gyp info using node-gyp@3.8.0
 gyp info using node@10.14.1 | linux | x64
 10.14.1
 gyp info ok
 [1/5] Validating package.json...
 [2/5] Resolving packages...
 error Couldn't find package "@eclipse-che/workspace-client@latest" required by "@eclipse-che/che-theia-hosted-plugin-manager-extension@7.2.0" on the "npm" registry.

So it's one step forward, one missing requirement in the npm offline cache back. :)

useful!
source:https://uonfu.com/
answerer
Nick Boldt nickboldt Red Hat CodeReady Existing Between Keyboard and Chair http://nick.divbyzero.com See http://nick.divbyzero.com/
Github User Rank List