我最近刚开始重新开始 Web 开发,我的电脑上已经安装了 Node.js。我试图运行npm install -g live-server
以使用 npm 的实时服务器。
这是我跑的时候返回的npm install -g live-server
。
ashle@DESKTOP-PFHHR2C MINGW64 ~/Desktop/npmtest
$ npm install -g live-server
npm WARN deprecated [email protected]: The package has been renamed to `open`
C:\Users\ashle\AppData\Roaming\npm\live-server -> C:\Users\ashle\AppData\Roaming\npm\node_modules\live-server\live-server.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\live-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ [email protected]
added 191 packages from 149 contributors in 22.221s
安装似乎工作正常;但是,当我运行时live-server
出现以下错误:
ashle@DESKTOP-PFHHR2C MINGW64 ~/Desktop/npmtest
$ live-server
Serving "C:\Users\ashle\Desktop\npmtest" at http://127.0.0.1:8080
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
我已经尝试使用此(https://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows)作为指南从 Windows 中完全删除 Node.js;但是,一旦我再次安装节点和实时服务器,它仍然返回相同的错误。
我检查了路径以确保 C:\Users\Webmaster\AppData\Roaming\npm 在那里。也许那里出了问题,因为我不小心删除了所有其他环境变量,或者我完全没有注意到我做错了什么?还有其他人遇到过这个问题吗?
编辑:我也试过安装 gulp。然后当我尝试运行它时安装了所说的软件包,弹出了相同的消息,所以我不认为它是实时服务器独有的问题。