使用npm run serve运行脚本时出现问题。这是我的packakge.json:
{
"name": "indecision-app",
"version": "1.0.0",
"main": "index.js",
"author": "hendrx",
"license": "MIT",
"scripts": {
"serve": "live-server public/",
"build-babel": "babel src/app.js --out-file=public/src/app.js --presets=env,react --watch"
},
"dependencies": {
"babel-cli": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"live-server": "^1.2.1"
}
}
在运行 npm run serve 时,出现以下错误:
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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! indecision-app@1.0.0 serve: `live-server public/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the indecision-app@1.0.0 serve script.
我尝试在计算机上卸载并重新安装node和npm,但该操作不起作用。如果我再次尝试运行 npm run serve 命令,则会收到上述相同错误。我的最终日志如下:
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 'run',
1 verbose cli 'serve' ]
2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle indecision-app@1.0.0~preserve: indecision-app@1.0.0
6 info lifecycle indecision-app@1.0.0~serve: indecision-app@1.0.0
7 verbose lifecycle indecision-app@1.0.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle indecision-app@1.0.0~serve: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\AKA\Desktop\react-course-project\indecision-app\node_modules\.bin;C:\Users\AKA\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin;C:\Program Files\ConEmu\ConEmu\Scripts;C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\Ruby25-x64\bin;C:\ProgramData\chocolatey\bin;C:\WINDOWS\system3;.;C:\Program Files\MongoDB\Server\4.0\bin;C:\Program Files (x86)\Google\Chrome\Application;C:\Program Files\Mozilla Firefox;C:\Program Files\Git\cmd;C:\Program Files (x86)\Brackets\command;C:\Program Files\nodejs;C:\Program Files (x86)\Yarn\bin;C:\WINDOWS\system3;.;C:\Program Files\heroku\bin;C:\Program Files\MongoDB\Server\4.0\bin;C:\Users\AKA\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\AKA\AppData\Roaming\npm;C:\Users\AKA\AppData\Local\Yarn\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle indecision-app@1.0.0~serve: CWD: C:\Users\AKA\Desktop\react-course-project\indecision-app
10 silly lifecycle indecision-app@1.0.0~serve: Args: [ '/d /s /c', 'live-server public/' ]
11 silly lifecycle indecision-app@1.0.0~serve: Returned: code: 1 signal: null
12 info lifecycle indecision-app@1.0.0~serve: Failed to exec serve script
13 verbose stack Error: indecision-app@1.0.0 serve: `live-server public/`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid indecision-app@1.0.0
15 verbose cwd C:\Users\AKA\Desktop\react-course-project\indecision-app
16 verbose Windows_NT 10.0.17763
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "serve"
18 verbose node v10.16.0
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error indecision-app@1.0.0 serve: `live-server public/`
22 error Exit status 1
23 error Failed at the indecision-app@1.0.0 serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
谢谢所有优秀的程序员。