1

嗨朋友我正在尝试使用npm install socket.io安装 socket.io 模块。它不工作我收到以下错误:

npm WARN package.json an-hybrid-app@0.1.0 No README.md file found!
npm http GET https://registry.npmjs.org/socket.io
npm http 200 https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/socket.io-client/0.9.11
npm http GET https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/base64id/0.1.0
npm http GET https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.11
npm http 304 https://registry.npmjs.org/policyfile/0.0.4
npm http 304 https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/base64id/0.1.0
npm http GET https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http GET https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/ws
npm http 304 https://registry.npmjs.org/uglify-js/1.2.5
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/zeparser/0.0.5
npm http GET https://registry.npmjs.org/options
npm http GET https://registry.npmjs.org/tinycolor
npm http GET https://registry.npmjs.org/commander
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
npm http 304 https://registry.npmjs.org/options
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/commander

> ws@0.4.25 install E:\chat_\nodejs\node_modules\socket.io\node_modules\socket.i
o-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

CreateProcessW: The system cannot find the file specified.
npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'E:\chat_\nodejs\node_module
s\socket.io\node_modules\socket.io-client\node_modules\active-x-obfuscator\node_
modules\zeparser'
npm ERR! error rolling back  socket.io-client@0.9.11 { [Error: ENOTEMPTY, rmdir
'E:\chat_\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modul
es\active-x-obfuscator\node_modules\zeparser']
npm ERR! error rolling back   errno: 53,
npm ERR! error rolling back   code: 'ENOTEMPTY',
npm ERR! error rolling back   path: 'E:\\chat_\\nodejs\\node_modules\\socket.io\
\node_modules\\socket.io-client\\node_modules\\active-x-obfuscator\\node_modules
\\zeparser' }
npm ERR! error rolling back Error: EPERM, readdir 'E:\chat_\nodejs\node_modules\
socket.io\node_modules\socket.io-client\node_modules\active-x-obfuscator\node_mo
dules\zeparser\benchmark.html'
npm ERR! error rolling back  socket.io@0.9.13 { [Error: EPERM, readdir 'E:\chat_
\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\active
-x-obfuscator\node_modules\zeparser\benchmark.html']
npm ERR! error rolling back   errno: 50,
npm ERR! error rolling back   code: 'EPERM',
npm ERR! error rolling back   path: 'E:\\chat_\\nodejs\\node_modules\\socket.io\
\node_modules\\socket.io-client\\node_modules\\active-x-obfuscator\\node_modules
\\zeparser\\benchmark.html' }
npm ERR! ws@0.4.25 install: `(node-gyp rebuild 2> builderror.log) || (exit 0)`
npm ERR! `cmd "/c" "(node-gyp rebuild 2> builderror.log) || (exit 0)"` failed wi
th 127
npm ERR!
npm ERR! Failed at the ws@0.4.25 install script.
npm ERR! This is most likely a problem with the ws package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     (node-gyp rebuild 2> builderror.log) || (exit 0)
npm ERR! You can get their info via:
npm ERR!     npm owner ls ws
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "socket.io"
npm ERR! cwd E:\chat_\nodejs
npm ERR! node -v v0.8.18
npm ERR! npm -v 1.2.2
npm ERR! code ELIFECYCLE
npm ERR! Error: ENOENT, lstat 'E:\chat_\nodejs\node_modules\socket.io\node_modul
es\socket.io-client\node_modules\active-x-obfuscator\node_modules\zeparser\bench
mark.html'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod  ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "socket.io"
npm ERR! cwd E:\chat_\nodejs
npm ERR! node -v v0.8.18
npm ERR! npm -v 1.2.2
npm ERR! path E:\chat_\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\active-x-obfuscator\node_modules\zeparser\benchmark.html

npm 错误!fstream_path E:\chat_\nodejs\node_modules\socket.io\node_modules\socket .io-client\node_modules\active-x-obfuscator\node_modules\zeparser\benchmark.html

npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     E:\chat_\nodejs\npm-debug.log
npm ERR! not ok code 0

我是 node.js 的新手,请帮助。在此先感谢。

4

2 回答 2

2

问题在于 ws 包。它只是找不到cmd.exePATH将 %SYSTEMROOT%\System32 或 C:\Windows\System32 的路径添加到您的环境

于 2013-04-06T10:30:51.837 回答
0

确保您拥有运行所需的所有软件node-gyp

您还可以node-gyp通过环境变量配置所使用的 Visual Studio 版本,这样您就可以避免--msvs_version=2012每次执行 npm 安装时都必须设置属性。

例子:

  • GYP_MSVS_VERSION=2012为 Visual Studio 2012设置
  • 设置GYP_MSVS_VERSION=2013e(“e”代表“特快版”)

有关完整列表,请参阅 - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

这对于 NodeJS 的 Windows 用户来说仍然很痛苦,因为它假定您安装了 Visual Studio 的副本,而许多最终用户永远不会拥有它。因此,我正在游说 Joyent 鼓励他们将 Web 套接字作为 CORE 节点的一部分,并可能将 GNU gcc 编译器作为 NodeJS 安装的一部分,这样我们就可以永久解决这个问题。

欢迎在以下位置添加您的投票:

于 2014-08-01T01:48:12.420 回答