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

npm_config_node_gyp environment variable #762

Closed
jlchereau opened this issue Oct 8, 2015 · 3 comments
Closed

npm_config_node_gyp environment variable #762

jlchereau opened this issue Oct 8, 2015 · 3 comments

Comments

@jlchereau
Copy link

I run node 4.1.2 on Windows 10 with VS 2015 Community Edition
#1) npm config

I have installed

npm install -g node-gyp

I have set:

npm config set msvs_version 2015
npm config set msvs_version 2015 --global

#2) npm install kerberos

Runing npm install kerberos yields the following error:

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\My Project>npm install kerberos
npm WARN package.json async@1.4.2 No README data
npm WARN package.json babel-core@5.8.25 No README data
npm WARN package.json dom-serializer@0.1.0 No README data
npm WARN package.json jade@0.26.3 No README data
npm WARN package.json coffee-script@1.3.3 bugs['name'] should probably be bugs['url'].
npm WARN package.json dateformat@1.0.2-1.2.3 No repository field.
npm WARN package.json eyes@0.1.8 No repository field.
npm WARN package.json pause@0.0.1 No repository field.
npm WARN package.json querystring@0.2.0 querystring is also the name of a node core module.
npm WARN package.json string_decoder@0.10.31 string_decoder is also the name of a node core module.
-
> kerberos@0.0.15 install C:\My Project\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)


C:\My Project\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
Traceback (most recent call last):
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 534, in script_main
    return main(sys.argv[1:])
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 527, in main
    return gyp_main(args)
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 503, in gyp_main
    options.circular_check)
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1867, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 402, in SelectVisualStudioVersion
    versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2015'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:343:16)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\My Project\node_modules\kerberos
gyp ERR! node -v v4.1.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
kerberos@0.0.15 node_modules\kerberos

Note that it uses node-gyp v1.0.3 when npm install -g node-gyp has installed v3.0.3.

This is solved by running:

npm config set node_gyp "node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js"

or

set npm_config_node_gyp=node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js

as demonstrated here below:

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\My Project>set npm_config_node_gyp=node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js

C:\My Project>npm install kerberos
npm WARN package.json async@1.4.2 No README data
npm WARN package.json babel-core@5.8.25 No README data
npm WARN package.json dom-serializer@0.1.0 No README data
npm WARN package.json jade@0.26.3 No README data
npm WARN package.json coffee-script@1.3.3 bugs['name'] should probably be bugs['url'].
npm WARN package.json dateformat@1.0.2-1.2.3 No repository field.
npm WARN package.json eyes@0.1.8 No repository field.
npm WARN package.json pause@0.0.1 No repository field.
npm WARN package.json querystring@0.2.0 querystring is also the name of a node core module.
npm WARN package.json string_decoder@0.10.31 string_decoder is also the name of a node core module.
|
> kerberos@0.0.15 install C:\My Project\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)


C:\My Project\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node C:\Users\jlche\AppData\R
oaming\npm\node_modules\node-gyp\bin\node-gyp.js rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  kerberos.cc
  worker.cc
  security_buffer.cc
  security_buffer_descriptor.cc
  security_context.cc
  security_credentials.cc
..\lib\win32\wrappers\security_context.cc(608): warning C4311: 'type cast': pointer truncation from 'unsigned long *' to 'unsigned long' [C:\My Project\node_modules\kerberos\build\kerberos.vcxproj]
..\lib\win32\wrappers\security_context.cc(608): warning C4302: 'type cast': truncation from 'unsigned long *' to 'unsigned long' [C:\My Project\node_modules\kerberos\build\kerberos.vcxproj]
  base64.c
  kerberos_sspi.c
  win_delay_load_hook.c
     Creating library C:\My Project\node_modules\kerberos\build\Release\kerberos.lib and object C:\My Project\node_modules\kerberos\build\Release\kerberos.exp
  Generating code
  Finished generating code
  kerberos.vcxproj -> C:\My Project\node_modules\kerberos\build\Release\\kerberos.node
kerberos@0.0.15 node_modules\kerberos

#3) npm install -g phonegap

Using the exact same configuration including the fix for installing kerberos, that is set npm_config_node_gyp=node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js

Running npm install -g phonegap now yields the following error:


C:\My Project>npm install -g phonegap
npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"4.1.2","npm":"2.7.4"})

> ws@0.4.31 install C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)


C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js rebuild ) 
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  bufferutil.cc
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\nan\nan.h(213): error C2039: 'ThrowException': is not a member of 'v8' [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\build\bufferutil.vcxproj]
  C:\Users\me\.node-gyp\4.1.2\include\node\v8.h(66): note: see declaration of 'v8'
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\nan\nan.h(213): error C2039: 'New': is not a member of 'v8::String' [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\build\bufferutil.vcxproj]
  C:\Users\me\.node-gyp\4.1.2\include\node\v8.h(2081): note: see declaration of 'v8::String'
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\nan\nan.h(213): error C3861: 'New': identifier not found [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\nan\nan.h(213): error C3861: 'ThrowException': identifier not found [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\nan\nan.h(218): error C2039: 'ThrowException': is not a member of 'v8' [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws\build\bufferutil.vcxproj]


[Let's cut some errors here ...]


  C:\Users\me\.node-gyp\4.1.2\include\node\v8.h(885): note: see declaration of 'v8::HandleScope::HandleScope'
  C:\Users\me\.node-gyp\4.1.2\include\node\v8.h(869): note: see declaration of 'v8::HandleScope'
..\src\validation.cc(109): error C2664: 'v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate *,v8::FunctionCallback,v8::Local<v8::Value>,v8::Local<v8::Signature>,int)': cannot convert argument 1 from 'void (__cdecl *)(const v8::FunctionCallbackInfo<v8::Value> &)' to 'v8::Isolate *' [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
  ..\src\validation.cc(109): note: There is no context in which this conversion is possible
..\src\validation.cc(112): error C2039: 'NewSymbol': is not a member of 'v8::String' [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
  C:\Users\me\.node-gyp\4.1.2\include\node\v8.h(2081): note: see declaration of 'v8::String'
..\src\validation.cc(112): error C3861: 'NewSymbol': identifier not found [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
..\src\validation.cc(134): error C2660: 'v8::True': function does not take 0 arguments [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
..\src\validation.cc(134): error C2660: 'v8::False': function does not take 0 arguments [C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
C:\Users\me\AppData\Roaming\npm\phonegap -> C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js
phonegap@5.3.6 C:\Users\me\AppData\Roaming\npm\node_modules\phonegap
├── pluralize@0.0.4
├── colors@0.6.0-1
├── semver@1.1.0
├── minimist@0.1.0
├── qrcode-terminal@0.9.4
├── shelljs@0.1.4
├── prompt@0.2.11 (revalidator@0.1.8, pkginfo@0.3.0, read@1.0.7, winston@0.6.2, utile@0.2.1)
├── phonegap-build@0.9.2 (colors@0.6.2, qrcode-terminal@0.8.0, shelljs@0.0.9, optimist@0.3.7, phonegap-build-api@0.3.3)
├── connect-phonegap@0.18.0 (home-dir@0.1.2, connect-inject@0.3.2, ip@0.3.1, adm-zip@0.4.7, request-progress@0.3.1, walkdir@0.0.8, http-proxy@1.8.1, shelljs@0.2.6, useragent@2.0.8, node-static@0.7.0, request@2.33.0, gaze@0.4.3, tar@0.1.19, localtunnel@1.3.0, archiv
er@0.14.3, connect@2.12.0, socket.io@1.0.4)
└── cordova@5.3.3 (underscore@1.7.0, q@1.0.1, nopt@3.0.1, cordova-lib@5.3.3)

This is fixed by running the same without setting environment variable npm_config_node_gyp as reproduced below:

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\My Project>npm install -g phonegap
npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"4.1.2","npm":"2.7.4"})

> ws@0.4.31 install C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

\
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\ws>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\nod
e_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)

> ws@0.4.31 install C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)


C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_mo
dules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
C:\Users\me\AppData\Roaming\npm\phonegap -> C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js
phonegap@5.3.6 C:\Users\me\AppData\Roaming\npm\node_modules\phonegap
├── pluralize@0.0.4
├── colors@0.6.0-1
├── semver@1.1.0
├── minimist@0.1.0
├── qrcode-terminal@0.9.4
├── shelljs@0.1.4
├── prompt@0.2.11 (revalidator@0.1.8, pkginfo@0.3.0, read@1.0.7, winston@0.6.2, utile@0.2.1)
├── phonegap-build@0.9.2 (colors@0.6.2, qrcode-terminal@0.8.0, shelljs@0.0.9, optimist@0.3.7, phonegap-build-api@0.3.3)
├── connect-phonegap@0.18.0 (home-dir@0.1.2, connect-inject@0.3.2, ip@0.3.1, adm-zip@0.4.7, request-progress@0.3.1, walkdir@0.0.8, http-proxy@1.8.1, shelljs@0.2.6, useragent@2.0.8, node-static@0.7.0, request@2.33.0, gaze@0.4.3, tar@0.1.19, localtunnel@1.3.0, archiv
er@0.14.3, connect@2.12.0, socket.io@1.0.4)
└── cordova@5.3.3 (underscore@1.7.0, q@1.0.1, nopt@3.0.1, cordova-lib@5.3.3)

#4) problem

Currently npm install kerberos won't work without setting environment variable npm_config_node_gyp after installing npm install -g node-gyp.

But npm install -g phonegap won't work unless environment variable npm_config_node_gyp is not set.

Is there a way to have a configuration that allows both npm install kerberos and npm install -g phonegap to work without setting/unsetting environment variables before running any such commands?

@bnoordhuis
Copy link
Member

Sorry, I'm going to close this, it's not an issue with node.js core or node-gyp, but with the packages you're trying to install.

On a side note, I'd refrain from installing node-gyp through npm. The version that is shipped with node.js is the one you should use, anything else is asking for trouble.

@ArslanMahmoodAnsari
Copy link

Please, still can you answer this question, I am facing the same problem and have the same issue, Please respond.

@bnoordhuis
Copy link
Member

You already have your answer: those packages are broken, they were written for an old version of node.js.

Aside: downvoting but still demanding an answer. Kinda rich, don't you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants