Node-gyp: How do I stop node-gyp from trying to to download node-headers?

Created on 5 Sep 2016  路  12Comments  路  Source: nodejs/node-gyp

I'm trying (but failing) to install gulp-sass which (I believe) is a module that must be compiled with node-gyp. I suspect that the problems I'm getting stem from a misconfiguration of my gyp setup. I've also raised this as an issue on the gulp-sass issue tracker:

https://github.com/dlmanning/gulp-sass/issues/530

The error seems to come quite close to the beginning of the process where it wants to get something from the Internet. Naturally this fails.

I'm working behind a corporate firewall. There's absolutely no way I can allow desktop applications to connect to the outside world. It's banned here.

Is there a work-around? For example, i could manually download the file that it's trying to install and then put it on this PC to prevent it hitting the Internet.

I'm using Windows 7.

Whenever I try to install gulp-sass I get the following error:

C:\workspace\CMOTStyles>npm install --save-dev gulp-sass

> [email protected] install C:\workspace\CMOTStyles\node_modules\gulp-sass\node_modules\node-sass
> node scripts/install.js

Start downloading binary at https://github.com/sass/node-sass/releases/download/v3.9.0/win32-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.9.0/win32-x64-48_binding.node":

getaddrinfo ENOTFOUND github.com github.com:443

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> [email protected] postinstall C:\workspace\CMOTStyles\node_modules\gulp-sass\node_modules\node-sass
> node scripts/build.js

Building: C:\apps\nodejs\node.exe C:\workspace\CMOTStyles\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\apps\\nodejs\\node.exe',
gyp verb cli   'C:\\workspace\\CMOTStyles\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\workspace\CMOTStyles\node_modules\which\which.js:14:12)
gyp verb `which` failed     at F (C:\workspace\CMOTStyles\node_modules\which\which.js:69:19)
gyp verb `which` failed     at E (C:\workspace\CMOTStyles\node_modules\which\which.js:81:29)
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\which\which.js:90:16
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:117:15)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\workspace\CMOTStyles\node_modules\which\which.js:14:12)
gyp verb `which` failed     at F (C:\workspace\CMOTStyles\node_modules\which\which.js:69:19)
gyp verb `which` failed     at E (C:\workspace\CMOTStyles\node_modules\which\which.js:81:29)
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\which\which.js:90:16
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:117:15) code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:\workspace\CMOTStyles\node_modules\which\which.js:14:12)
gyp verb `which` failed     at F (C:\workspace\CMOTStyles\node_modules\which\which.js:69:19)
gyp verb `which` failed     at E (C:\workspace\CMOTStyles\node_modules\which\which.js:81:29)
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\which\which.js:90:16
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:117:15)
gyp verb `which` failed  python { Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:\workspace\CMOTStyles\node_modules\which\which.js:14:12)
gyp verb `which` failed     at F (C:\workspace\CMOTStyles\node_modules\which\which.js:69:19)
gyp verb `which` failed     at E (C:\workspace\CMOTStyles\node_modules\which\which.js:81:29)
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\which\which.js:90:16
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\workspace\CMOTStyles\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:117:15) code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb check python launcher python executable found: "C:\\Python27\\python.exe"
gyp verb check python version `C:\Python27\python.exe -c "import platform; print(platform.python_version());"` returned: "2.7.10\r\n"
gyp verb get node dir no --target version specified, falling back to host node version: 6.2.0
gyp verb command install [ '6.2.0' ]
gyp verb install input version string "6.2.0"
gyp verb install installing version: 6.2.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 6.2.0
gyp verb ensuring nodedir is created C:\Users\NBKA0O5\.node-gyp\6.2.0
gyp verb created nodedir C:\Users\NBKA0O5\.node-gyp\6.2.0
gyp http GET https://nodejs.org/download/release/v6.2.0/node-v6.2.0-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp verb command remove [ '6.2.0' ]
gyp verb remove using node-gyp dir: C:\Users\NBKA0O5\.node-gyp
gyp verb remove removing target version: 6.2.0
gyp verb remove removing development files for version: 6.2.0
gyp ERR! configure error
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 or have bad
gyp ERR! stack network settings.
gyp ERR! stack     at Request.<anonymous> (C:\workspace\CMOTStyles\node_modules\node-gyp\lib\install.js:193:21)
gyp ERR! stack     at emitOne (events.js:96:13)
gyp ERR! stack     at Request.emit (events.js:188:7)
gyp ERR! stack     at Request.onRequestError (C:\workspace\CMOTStyles\node_modules\request\request.js:813:8)
gyp ERR! stack     at emitOne (events.js:96:13)
gyp ERR! stack     at ClientRequest.emit (events.js:188:7)
gyp ERR! stack     at TLSSocket.socketErrorListener (_http_client.js:306:9)
gyp ERR! stack     at emitOne (events.js:96:13)
gyp ERR! stack     at TLSSocket.emit (events.js:188:7)
gyp ERR! stack     at connectErrorNT (net.js:1015:8)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\apps\\nodejs\\node.exe" "C:\\workspace\\CMOTStyles\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\workspace\CMOTStyles\node_modules\gulp-sass\node_modules\node-sass
gyp ERR! node -v v6.2.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
Build failed
npm WARN enoent ENOENT: no such file or directory, open 'C:\workspace\CMOTStyles\node_modules\node-sass\package.json'
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] license should be a valid SPDX license expression
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\apps\\nodejs\\node.exe" "C:\\Users\\NBKA0O5\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "gulp-sass"
npm ERR! node v6.2.0
npm ERR! npm  v3.10.6
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node scripts/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\workspace\CMOTStyles\npm-debug.log

Most helpful comment

  1. Download the file from "https://github.com/sass/node-sass/releases/download/v3.9.0/win32-x64-48_binding.node" and save it as , say, c:\Temp\win32-x64-48_binding.node .
  2. run SET SASS_BINARY_PATH = C:\Temp\win32-x64-48_binding.node
  3. run your npm install again.

All 12 comments

You can use the --tarball or --nodedir switches if you don't want to or can't download the SDK directly. The second switch is for when you have a node source checkout on disk somewhere.

Is this an option for setting up gulp-sass or for node-gyp? Also is there a way to permanently set this so that my npm "just works"?

node-gyp. You can set it in your .npmrc.

EDIT: Or through the npm_config_tarball and npm_config_nodedir environment variables.

For reference, the command to set nodedir in npm is

npm config set nodedir DIRECTORY
  1. Download the file from "https://github.com/sass/node-sass/releases/download/v3.9.0/win32-x64-48_binding.node" and save it as , say, c:\Temp\win32-x64-48_binding.node .
  2. run SET SASS_BINARY_PATH = C:\Temp\win32-x64-48_binding.node
  3. run your npm install again.

Looks like this is answered? If not please let us know.

What do the numbers represent in the releases? e.g. in c:\Temp\win32-x64-48_binding.node what does the 48 represent?

Thanks!

At a guess NODE_MODULE_VERSION, see the table on https://nodejs.org/en/download/releases/ to map back to the Node.js version.

Tracing a little bit from "node scripts/install.js"
the number in human form (getHumanNodeVersion):
https://github.com/sass/node-sass/blob/master/lib/extensions.js#L61

Brilliant, thanks folks. I'm not sure why my yarn --offline is still looking for gyp http GET https://nodejs.org/download/release/v6.14.2/node-v6.14.2-headers.tar.gz. I've specified sass-binary-path "./npm-packages-offline-cache/linux-x64-48_binding.node" in .yarnrc

For some reason a relative path didn't work for me (although it did for the offline cache)

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

yarn-offline-mirror "./npm-packages-offline-cache"
sass-binary-path "/home/ash/dev/offline-test/npm-packages-offline-cache/linux-x64-48_binding.node"

I ran yarn install --offline from /home/ash/dev/offline-test. It works now with the full path (as above), but didn't work when I had ./npm-packages-offline-cache/linux-x64-48_binding.node

It seems that it MUST be the full path, which is annoying as I wanted to check a relative path into my project with .yarnrc. Here is where it is mentioned https://github.com/sass/node-sass/issues/2081

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lopezdp picture lopezdp  路  3Comments

swaj picture swaj  路  3Comments

kimown picture kimown  路  3Comments

gengjiawen picture gengjiawen  路  3Comments

jhermsmeier picture jhermsmeier  路  3Comments