Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-gyp rebuild downloads headers from incorrect location #787

Closed
mgol opened this issue Oct 28, 2015 · 31 comments
Closed

node-gyp rebuild downloads headers from incorrect location #787

mgol opened this issue Oct 28, 2015 · 31 comments

Comments

@mgol
Copy link

mgol commented Oct 28, 2015

I thought that node-gyp 3.0.3 should have this all fixed by taking the data from process.release but it still downloads from the default one for me:

$ node --version
v4.2.1
$ npm --version
3.3.10
$ node -p process.release
{ name: 'node',
  lts: 'Argon',
  sourceUrl: 'https://nodejs.org/download/release/v4.2.1/node-v4.2.1.tar.gz',
  headersUrl: 'https://nodejs.org/download/release/v4.2.1/node-v4.2.1-headers.tar.gz' }

$ npm i node-sass@3.4.1

Switch to Node 5 & then (notice the incorrect URL https://nodejs.org/dist/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz):

$ node --version
v5.0.0-rc.1
$ npm --version
3.3.10
$ node -p process.release
{ name: 'node',
  sourceUrl: 'https://nodejs.org/download/rc/v5.0.0-rc.1/node-v5.0.0-rc.1.tar.gz',
  headersUrl: 'https://nodejs.org/download/rc/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz' }
$ npm rebuild node-sass

> node-sass@3.4.1 install /Users/mgol/_/node_modules/node-sass
> node scripts/install.js

Cannot download "https://github.com/sass/node-sass/releases/download/v3.4.1/darwin-x64-47_binding.node": 

HTTP error 404 Not Found

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

> node-sass@3.4.1 postinstall /Users/mgol/_/node_modules/node-sass
> node scripts/build.js

Building: /Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/node /Users/mgol/_/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 [ '/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/node',
gyp verb cli   '/Users/mgol/_/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 node-gyp@3.0.3
gyp info using node@5.0.0-rc.1 | darwin | 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 F (/Users/mgol/_/node_modules/which/which.js:78:19)
gyp verb `which` failed     at E (/Users/mgol/_/node_modules/which/which.js:82:29)
gyp verb `which` failed     at /Users/mgol/_/node_modules/which/which.js:93:16
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python2 [Error: not found: python2]
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `python -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: 5.0.0-rc.1
gyp verb command install [ '5.0.0-rc.1' ]
gyp verb install input version string "5.0.0-rc.1"
gyp verb install installing version: 5.0.0-rc.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 5.0.0-rc.1
gyp verb ensuring nodedir is created /Users/mgol/.node-gyp/5.0.0-rc.1
gyp verb created nodedir /Users/mgol/.node-gyp/5.0.0-rc.1
gyp http GET https://nodejs.org/dist/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz
gyp http 404 https://nodejs.org/dist/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp verb command remove [ '5.0.0-rc.1' ]
gyp verb remove using node-gyp dir: /Users/mgol/.node-gyp
gyp verb remove removing target version: 5.0.0-rc.1
gyp verb remove removing development files for version: 5.0.0-rc.1
gyp ERR! configure error 
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz
gyp ERR! stack     at Request.<anonymous> (/Users/mgol/_/node_modules/node-gyp/lib/install.js:244:14)
gyp ERR! stack     at emitOne (events.js:82:20)
gyp ERR! stack     at Request.emit (events.js:169:7)
gyp ERR! stack     at Request.onRequestResponse (/Users/mgol/_/node_modules/request/request.js:998:10)
gyp ERR! stack     at emitOne (events.js:77:13)
gyp ERR! stack     at ClientRequest.emit (events.js:169:7)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient (_http_client.js:418:21)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:308:20)
gyp ERR! stack     at emitOne (events.js:77:13)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/node" "/Users/mgol/_/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/mgol/_/node_modules/node-sass
gyp ERR! node -v v5.0.0-rc.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
Build failed

npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/node" "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/npm" "rebuild" "node-sass"
npm ERR! node v5.0.0-rc.1
npm ERR! npm  v3.3.10
npm ERR! code ELIFECYCLE
npm ERR! node-sass@3.4.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.4.1 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 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!     /Users/mgol/_/npm-debug.log
@mgol
Copy link
Author

mgol commented Oct 28, 2015

Actually, just running npm i node-sass in a fresh directory with Node 5.0.0-rc.1 is giving those errors. No need to rebuild.

I reported it also to node-sass in case it's their fault: sass/node-sass#1224

@rvagg
Copy link
Member

rvagg commented Oct 28, 2015

$ rm -rf ~/.node-gyp/5.0.0-rc.1/
$ npm i bufferutil
npm http request GET https://registry.npmjs.org/bufferutil
npm http 304 https://registry.npmjs.org/bufferutil
npm http request GET https://registry.npmjs.org/bindings
npm http request GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/nan

> bufferutil@1.2.1 install /Users/rvagg/node_modules/bufferutil
> node-gyp rebuild

gyp http GET https://nodejs.org/download/rc/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/rc/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz
gyp http GET https://nodejs.org/download/rc/v5.0.0-rc.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/rc/v5.0.0-rc.1/SHASUMS256.txt
  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
...

note the correct url

$ /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js -v
v3.0.3
$ npm -v
3.3.6

@mgol
Copy link
Author

mgol commented Oct 28, 2015

@rvagg @saper So, it seems unrelated to node-sass after all. I can't reproduce your success in installing bufferutils, either on npm@3.3.6 or npm@3.3.10 so either npm or node-gyp seems to be to blame; not sure why it works for you...

$ npm i bufferutil  

> bufferutil@1.2.1 install /Users/mgol/_/node_modules/bufferutil
> node-gyp rebuild

gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v5.0.0-rc.1/node-v5.0.0-rc.1-headers.tar.gz
gyp ERR! stack     at Request.<anonymous> (/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:244:14)
gyp ERR! stack     at emitOne (events.js:82:20)
gyp ERR! stack     at Request.emit (events.js:169:7)
gyp ERR! stack     at Request.onRequestResponse (/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/request/request.js:998:10)
gyp ERR! stack     at emitOne (events.js:77:13)
gyp ERR! stack     at ClientRequest.emit (events.js:169:7)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient (_http_client.js:418:21)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:308:20)
gyp ERR! stack     at emitOne (events.js:77:13)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/node" "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mgol/_/node_modules/bufferutil
gyp ERR! node -v v5.0.0-rc.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
npm WARN ENOENT ENOENT: no such file or directory, open '/Users/mgol/_/package.json'
npm WARN EPACKAGEJSON /Users/mgol/_ No description
npm WARN EPACKAGEJSON /Users/mgol/_ No repository field.
npm WARN EPACKAGEJSON /Users/mgol/_ No README data
npm WARN EPACKAGEJSON /Users/mgol/_ No license field.
npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/node" "/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/bin/npm" "i" "bufferutil"
npm ERR! node v5.0.0-rc.1
npm ERR! npm  v3.3.6
npm ERR! code ELIFECYCLE

npm ERR! bufferutil@1.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bufferutil@1.2.1 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bufferutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls bufferutil
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mgol/_/npm-debug.log

@saper
Copy link
Contributor

saper commented Oct 28, 2015

@rvagg @saper So, it seems unrelated to node-sass after all. I can't reproduce your success in installing bufferutils, either on npm@3.3.6 or npm@3.3.10 so either npm or node-gyp seems to be to blame; not sure why it works for you...

$ npm i bufferutil  

> bufferutil@1.2.1 install /Users/mgol/_/node_modules/bufferutil
> node-gyp rebuild

What does this say?

find /Users/mgol -name node-gyp

@mgol
Copy link
Author

mgol commented Oct 28, 2015

$ find /Users/mgol -name node-gyp
/Users/mgol/.heroku/node-v4.1.1-darwin-x64/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.heroku/node-v4.1.1-darwin-x64/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.npm/node-gyp
/Users/mgol/.npm/registry.npmjs.org/node-gyp
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.0/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.0/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/Documents/projects/public/node/deps/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/Documents/projects/public/node/deps/npm/node_modules/node-gyp
/Users/mgol/Documents/projects/public/node-sass/node_modules/.bin/node-gyp
/Users/mgol/Documents/projects/public/node-sass/node_modules/node-gyp

plus some other unrelated packages under /Users/mgol/Documents/projects/.

@saper
Copy link
Contributor

saper commented Oct 28, 2015

On Wed, 28 Oct 2015, Michał Gołębiowski wrote:

$ find /Users/mgol -name node-gyp
/Users/mgol/.heroku/node-v4.1.1-darwin-x64/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.heroku/node-v4.1.1-darwin-x64/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.npm/node-gyp
/Users/mgol/.npm/registry.npmjs.org/node-gyp
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.0/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.0/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/.bin/node-gyp
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/node-gyp
/Users/mgol/Documents/projects/public/node/deps/npm/bin/node-gyp-bin/node-gyp
/Users/mgol/Documents/projects/public/node/deps/npm/node_modules/node-gyp
/Users/mgol/Documents/projects/public/node-sass/node_modules/.bin/node-gyp
/Users/mgol/Documents/projects/public/node-sass/node_modules/node-gyp
  • some other unrelated packages under /Users/mgol/Documents/projects/.

and all of them are 3.0.3 ? ... I also wonder why npm@3 in its awesomeness
still installs node-gyp under node-sass/node_modules/node-gyp ? Is there some
other node-gyp version in the way?

@mgol
Copy link
Author

mgol commented Oct 28, 2015

I also wonder why npm@3 in its awesomeness
still installs node-gyp under node-sass/node_modules/node-gyp

The global lib/node_modules contains only directly installed packages, trees are flattened only in their own node_modules (see npm/npm#9593 (comment))

$ find /Users/mgol -path \*/bin/node-gyp.js -exec echo {} \; -exec node {} -v \;
/Users/mgol/.heroku/node-v4.1.1-darwin-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.1
/Users/mgol/.nvm/v0.10.40/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/.nvm/versions/node/v0.12.7/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/.nvm/versions/node/v4.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/david/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/.nvm/versions/node/v5.0.0-rc.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/Documents/projects/public/node/deps/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/Documents/projects/public/node-sass/node_modules/node-gyp/bin/node-gyp.js
v3.0.3
/Users/mgol/Documents/projects/public/npm/node_modules/node-gyp/bin/node-gyp.js
v3.0.3

@targos
Copy link
Member

targos commented Oct 28, 2015

@mzgol all of this is because we are using nvm.
Copy from nodejs/node#3466 (comment):
It's because of nvm's env variable NVM_NODEJS_ORG_MIRROR that is equal to https://nodejs.org/dist and is used by node-gyp. Is it really necessary to read this variable ?

@targos
Copy link
Member

targos commented Oct 28, 2015

@mzgol does it work for you with NVM_NODEJS_ORG_MIRROR="" npm i bufferutil ?

@mgol
Copy link
Author

mgol commented Oct 28, 2015

Shoot, I thought I unloaded nvm correctly before replying to sass/node-sass#1224 (comment) but it seems I didn't do it correctly... I've just tried again and it works without nvm.

Is there any reason to read NVM_NODEJS_ORG_MIRROR? It doesn't seem to make sense to read it since it's no longer a single URL prefix for all versions.

@mgol
Copy link
Author

mgol commented Oct 28, 2015

@targos Yup, NVM_NODEJS_ORG_MIRROR="" npm i bufferutil works fine.

@rvagg
Copy link
Member

rvagg commented Oct 28, 2015

NVM_NODEJS_ORG_MIRROR is now read by node-gyp to allow mirrors of nodejs.org, mainly people in China. Are you setting NVM_NODEJS_ORG_MIRROR yourself or is nvm doing it? If this is something that nvm does as standard then I'm more concerned, if you're setting it then at least you know what the problem is now.

Also, this is just for the RC, when v5.0.0 goes live it'll be fetchable in /dist/ as expected.

@targos
Copy link
Member

targos commented Oct 29, 2015

nvm is setting NVM_NODEJS_ORG_MIRROR if it doesn't already exist:
https://github.com/creationix/nvm/blob/master/nvm.sh#L87-L94

@rvagg
Copy link
Member

rvagg commented Oct 29, 2015

argh

@ljharb: this is going to have to change if you want to support release candidates, node-gyp is now using NVM_NODEJS_ORG_MIRROR as well. Alternatively we could remove it from node-gyp but we'll have to come up with an alternative to support people needing mirrors.

@mgol
Copy link
Author

mgol commented Oct 29, 2015

It's surprising to me that node-gyp reads NVM_ env variables which should be reserved for nvm. If an env. variable to set up mirror URLs is desired, I'd expect them to be generic and not influenced by NVM. After all, not only nvm users might want to use those mirrors.

I initially thought it's a node-sass issue because I had a feeling nvm couldn't break Node in such a way. My intuition was partially right... I just didn't expect node-gyp to rely on nvm config.

@mgol
Copy link
Author

mgol commented Oct 29, 2015

nvm uses NVM_NODEJS_ORG_MIRROR internally as the URL from which Node versions are to be downloaded. Therefore, this variable has to be set by nvm before any Node is activated yet. This logic may be incompatible with future plans to add RC support to nvm, I'd expect more than one env. variable to be used, each for a separate release type (unless all mirrors follow the same pattern of putting RC versions under /rc/) which will make this node-gyp logic incorrect anyway.

This shows to me that node-gyp should use a separate variable, otherwise it implicitly depends on internal nvm logic that might change in the future. It's fragile.

@ljharb
Copy link
Member

ljharb commented Oct 30, 2015

@rvagg um - yes, reading nvm's internal env variables (instead of just using them to modify nvm's behavior) is a very bad idea. I've changed these before as a non-breaking change.

I think what would make more sense is a node-gyp specific env var for mirrors.

I don't see how this impacts RC support, as I won't at all be changing the mirror logic for it.

@noamokman
Copy link

Maybe node-gyp should use somthing like electron-downloader.
Electron uses this tool for other electorn products (electron-prebuilt and electron-packager)
And it has a shared env variable to set the mirror.

Maybe we should write a node-downloader? for headers and source. So its official in one place.
That way, developers depending on the node dist url could use the package.

@rvagg
Copy link
Member

rvagg commented Nov 12, 2015

I think we're just going to have to remove NVM_NODEJS_ORG_MIRROR and invent our own env var for this.

@noamokman node-gyp is that downloader, there shouldn't be a need for a separate tool, the logic is all in here.

@saper
Copy link
Contributor

saper commented Nov 12, 2015

I have always thought this feature is in the node-gyp only to address some (arguable) shortcoming in how the node itself is packaged: I always get my current node include and .gyp files installed in /usr/local/include/node. One could imagine that this could be shipped as a part of the node distribution or as a separate node-dev-alike package.

With this issue solved node-gyp could just be a thin layer over gyp, that works 100% offline.

I am always installing necessary header files in /usr/local/include/node and I always use --nodedir option to skip a whole verify-and-maybe-download step at all. (FreeBSD port takes care of installing the includes for me so it always matches my node version).

@harrygfox
Copy link

+1
Unable to:
npm install node-sass for this reason

@brancusi
Copy link

brancusi commented Dec 4, 2015

+1 on this.
Unable to: npm i node-sass using nvm.

Going through this thread but I'm not understanding the workaround. Could someone explain in moron terms?

@rvagg
Copy link
Member

rvagg commented Feb 11, 2016

I propose we introduce NODEJS_ORG_MIRROR to node-gyp, completely replacing NVM_NODEJS_ORG_MIRROR. It was clearly a mistake to introduce it but it was done in response to a request by Chinese users who were already using that functionality with nvm.

It'll be a breaking change so we'll have to bump semver-major and we'll have to communicate the change to users, the README is probably the best we can do on that front.

@ralphtheninja
Copy link
Contributor

I propose we introduce NODEJS_ORG_MIRROR to node-gyp, completely replacing NVM_NODEJS_ORG_MIRROR. It was clearly a mistake to introduce it but it was done in response to a request by Chinese users who were already using that functionality with nvm.

👍

@mgol
Copy link
Author

mgol commented Feb 11, 2016 via email

@ljharb
Copy link
Member

ljharb commented Feb 11, 2016

Makes sense. I'm sure someone will request that nvm support NODEJS_ORG_MIRROR as well.

@rvagg could you add NODEJS_ORG_MIRROR as a semver-minor change now, supporting both, and then wait for the next semver-major to drop support for NVM_NODEJS_ORG_MIRROR?

@rvagg
Copy link
Member

rvagg commented Feb 12, 2016

yes, good call @ljharb, I need to get the headers download in for 0.12.10 and 0.10.42 in before we bump a major anyway so I'll try and bundle that and hopefully it'll be palatable enough for npm to include in v2

@rvagg
Copy link
Member

rvagg commented Feb 12, 2016

solution @ #878, reviewers welcome

@rvagg
Copy link
Member

rvagg commented Feb 16, 2016

we've moved a step closer with v3.3.0 just out that introduces NODEJS_ORG_MIRROR and IOJS_ORG_MIRROR and deprecates the NVM_* versions of them and prints a warning on use. We'll remove those completely from v4 (timeline to be decided ..)

@viviancpy
Copy link

In case anyone still come here because npm install node-sass cannot be executed because he/she is behind a corporate proxy or needs to work offline.

The root cause of the problem is the post-script of node-sass cannot download binding.node from github.

Cannot download "https://github.com/sass/node-sass/releases/download/v3.4.1/darwin-x64-47_binding.node":

We need provide the file before it goes to github. Steps:

  1. Download https://github.com/sass/node-sass/releases/download/v3.4.1/darwin-x64-47_binding.node (or anything comes up in the cannot download ... error message)
  2. Save the file to a local folder, say C:\Temp\darwin-x64-47_binding.node
  3. SET SASS_BINARY_PATH = C:\Temp\darwin-x64-47_binding.node
  4. Run npm install node-sass

@wawz
Copy link

wawz commented Jun 20, 2022

for me:
// 切换淘宝源
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
//先安装dart-sass
npm install node-sass@npm:dart-sass
//安装成功后再安装sass和sass-loader
npm install sass sass-loader

can work.

@nodejs nodejs locked as resolved and limited conversation to collaborators Jun 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests