将脚本添加到我的 package.json 文件后,如下所示。
{
"name": "indecision-app",
"version": "1.0.0",
"main":"index.js",
"author": "hendrx",
"license": "MIT",
"scripts": {
"serve": "live-server public/"
},
"dependencies": {
"babel-cli": "^6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"live-server": "^1.2.1"
},
"devDependencies": {}
}
我尝试运行
npm运行服务
在公用文件夹中启动实时服务器。但是我收到此日志错误
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\AKA\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'serve'
1 verbose cli ]
2 info using npm@6.9.0
3 info using node@v12.6.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:\Users\AKA\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\AKA\Desktop\react-course-project\indecision-app\node_modules\.bin;C:\Ruby25-x64\bin;C:\ProgramData\chocolatey\bin;"C:\WINDOWS\system32;";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:\Program Files\heroku\bin;C:\Users\AKA\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\AKA\AppData\Roaming\npm;C:\Users\AKA\AppData\Local\Yarn\bin
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:\Users\AKA\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:203:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\AKA\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:203:13)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283: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:\\Users\\AKA\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "serve"
18 verbose node v12.6.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 ]
请我不知道这里出了什么问题,也不想将 live-server 安装为全局依赖项。