installing ws with npm causes error with node-gyp

2019-02-25 13:53发布

问题:

I am working with:

Windows 10 64bit Node 0.12.7 NPM : 2.11.3

I am going through a MEAN stack tutorial, i am trying to run the following:

npm install --save ws

I get this error message:

C:\Dev\workspace\MeanProject\NodeServer>npm install --save ws
npm WARN package.json socialapp@ No description
npm WARN package.json socialapp@ No repository field.
npm WARN package.json socialapp@ No README data
npm WARN package.json socialapp@ No license field.
/
> utf-8-validate@1.2.1 install C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild


C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targe
ts(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the regi
stry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid versi
on number. [C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_mo
dules\utf-8-validate\build\validation.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the
 file specified. [C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\n
ode_modules\utf-8-validate\build\validation.vcxproj]


gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok

> bufferutil@1.2.1 install C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild


C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targe
ts(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the regi
stry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid versi
on number. [C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_mo
dules\bufferutil\build\bufferutil.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the
 file specified. [C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\n
ode_modules\bufferutil\build\bufferutil.vcxproj]


gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Dev\workspace\MeanProject\NodeServer\node_modules\ws\node_modules\bufferutil
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.2.1
npm WARN optional dep failed, continuing bufferutil@1.2.1
ws@0.8.0 node_modules\ws

I have the 2015 VS.

Any help would be appreciated.

回答1:

CL.exe is part of C++ dev environment. It is not installed by default. So, creating a new C++ Project in Visual Studio installs all needed components, including cl.exe. You can find it under "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe" and it's on path when launching "Developer Command Prompt for VS2015."



回答2:

This is because of running older version of gcc. Install the latest and the issue will be solved. Check this out for more details: https://github.com/assaf/zombie/issues/956



标签: npm