node.js - 如何使用 npm run build 修复此错误?
问题描述
运行 npm run build 时出现以下错误。我还有一个名为 npm run fresh build 的命令,它一个接一个地运行 3 个命令,但似乎问题出在 run build 命令上。下面是我的代码和我得到的错误。
"scripts": {
"fresh-build": "npm update && npm prune && npm run build",
"build": "rimraf dist && webpack --progress --profile --display-
chunks --bail",
这是我得到的错误:
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! nitrogen@0.8.0 build: `rimraf dist && webpack --progress --
profile --display-chunks --bail`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the nitrogen@0.8.0 build script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ldb/.npm/_logs/2019-02-01T07_15_27_998Z-
debug.log`
以下是日志文件的内容:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@5.6.0
3 info using node@v8.11.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle nitrogen@0.8.0~prebuild: nitrogen@0.8.0
6 info lifecycle nitrogen@0.8.0~build: nitrogen@0.8.0
7 verbose lifecycle nitrogen@0.8.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle nitrogen@0.8.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/ldb/Documents/Development/Work/Nitrogen/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle nitrogen@0.8.0~build: CWD: /Users/ldb/Documents/Development/Work/Nitrogen
10 silly lifecycle nitrogen@0.8.0~build: Args: [ '-c',
10 silly lifecycle 'rimraf dist && webpack --progress --profile --display-chunks --bail' ]
11 silly lifecycle nitrogen@0.8.0~build: Returned: code: 2 signal: null
12 info lifecycle nitrogen@0.8.0~build: Failed to exec build script
13 verbose stack Error: nitrogen@0.8.0 build: `rimraf dist && webpack --progress --profile --display-chunks --bail`
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid nitrogen@0.8.0
15 verbose cwd /Users/ldb/Documents/Development/Work/Nitrogen
16 verbose Darwin 18.0.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v8.11.3
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error nitrogen@0.8.0 build: `rimraf dist && webpack --progress --profile --display-chunks --bail`
22 error Exit status 2
23 error Failed at the nitrogen@0.8.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
解决方案
推荐阅读
- shopify - 如何在单独的标签中显示 Shopify 产品项目变体?
- regex - Bash 是否支持非贪婪正则表达式?
- python - Python根据if条件更新列
- javascript - 使用nodejs将图像上传到预签名的url
- outlook - Outlook 2016 RTF 格式 > 更新约会正文
- apache-kafka - Kafka 在 docker 中连接
- mongodb - 更新/提取包含在 Mongodb/Mongoose 中的子文档数组中的数组中的值
- firebase - “无法从构建环境中获取 Google 服务文件中的 GOOGLE_APP_ID”错误
- agda - 阿格达从杜布特?(引理的位置有不同的含义)
- android - Android `Reformat code` 选项重新排列我的视图在布局中的顺序