"npm faq"在Windows 7上失败("spawn ENOENT"错误)

Man*_*anu 7 windows node.js npm

我在Windows 7上安装了最新安装程序的node.js. 它似乎工作,我可以打电话npm和node从控制台(或者CMD或PowerShell的),但我不断收到错误.

关于windows上的node.js,这里有很多问题,但它们都提到了一些特定的代码.我正在使用许多简单的命令获得"spawn ENOENT",例如yo,如果我选择"更新生成器":

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)
Run Code Online (Sandbox Code Playgroud)

甚至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>
Run Code Online (Sandbox Code Playgroud)

似乎问题是节点使用unix命令名称dir,在Windows上不存在.一些博客文章提到使用Cygwin,但主要用于构建 node.js,而不是用于调用它.官方nodejs网站也没有提到cygwin也是先决条件.

这是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 ]
Run Code Online (Sandbox Code Playgroud)

小智 4

确保“路径”系统变量中有 c:\Windows\System32。我遇到了这个确切的问题,这就是我需要的修复。我一定是在过去某个时候错误地把它取出来的。