“npm 常见问题"在 Windows 7 上失败(“spawn ENOENT"错误) [英] "npm faq" fails on Windows 7 ("spawn ENOENT" errors)
问题描述
我已经使用最新的安装程序在 Windows 7 上安装了 node.js.它似乎有效,我可以从控制台(cmd 或 PowerShell)调用 npm
和 node
,但我不断收到错误.
I have installed node.js on Windows 7 with their latest installer. It seemed to work, I can call npm
and node
from the console (either cmd or PowerShell), but I keep getting errors.
这里有很多关于windows上node.js的问题,但都提到了一些特定的代码.如果我选择更新生成器",我将使用许多简单的命令获得生成 ENOENT",例如 yo
:
There are a lot of questions here about node.js on windows, but they all mention some specific piece of code. I'm getting the "spawn ENOENT" with a lot of simple commands, for instance yo
, if I then pick "update generators" :
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)
即使 npm faq
也失败:
PS E:\www\something> npm faq
npm ERR! Error: spawn ENOENT
npm ERR! at errnoException (child_process.js:988:11)
npm ERR! at Process.ChildProcess._handle.onexit (child_process.js:779:34)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/isaacs/npm/issues>
问题似乎是 node 使用了像 dir
这样的 unix 命令名称,而这些名称在 Windows 上不存在.一些博客文章提到使用 Cygwin,但主要用于构建 node.js,而不是调用它.nodejs 官方网站也没有提到 cygwin 是先决条件.
It seems that the problem is that node uses unix command names like dir
, which do not exist on Windows. Some blog posts mention using Cygwin, but mostly for building node.js, not for calling it. The official nodejs website doesn't mention that cygwin is a prerequisite, either.
这是 npm-debug.log :
Here's the npm-debug.log :
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'faq' ]
2 info using npm@1.3.24
3 info using node@v0.10.25
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 error Error: spawn ENOENT
5 error at errnoException (child_process.js:988:11)
5 error at Process.ChildProcess._handle.onexit (child_process.js:779:34)
6 error If you need help, you may report this *entire* log,
6 error including the npm and node versions, at:
6 error <http://github.com/isaacs/npm/issues>
7 error System Windows_NT 6.1.7601
8 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "faq"
9 error cwd E:\
10 error node -v v0.10.25
11 error npm -v 1.3.24
12 error syscall spawn
13 error code ENOENT
14 error errno ENOENT
15 verbose exit [ 1, true ]
推荐答案
确保您的路径"系统变量中有 c:\Windows\System32.我遇到了这个确切的问题,这是我需要的修复.我一定是在过去的某个时候错误地取出了它.
Make sure that you have c:\Windows\System32 on your 'Path' System Variable. I was having this exact problem and this was the fix I needed. I must have taken it out in error sometime in the past.
这篇关于“npm 常见问题"在 Windows 7 上失败(“spawn ENOENT"错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!