最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】npm run build项目出错:npm ERR! code ELIFECYCLE errno 2

npm crifan 40491浏览 0评论

折腾:

【部分解决】ReactJS中react-mobile-datepicker中input被设置readonly时无法滚动选择日期

期间,对于preact项目,之前

npm run build

都一直正常的,此处突然不正常出错了:

出错了:

        + 1 hidden modules
Child extract-text-webpack-plugin:
       [0] ../~/css-loader/lib/css-base.js 2.26 kB {0} [built]
        + 1 hidden modules
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `cross-env NODE_ENV=production webpack -p –progress`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] 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/crifan/.npm/_logs/2017-07-22T03_15_05_506Z-debug.log

去看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 [email protected]
3 info using [email protected]
4 verbose run-script [ ‘prebuild’, ‘build’, ‘postbuild’ ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 verbose lifecycle [email protected]~prebuild: unsafe-perm in lifecycle true
7 verbose lifecycle [email protected]~prebuild: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/crifan/dev/dev_root/daryun/Projects/奥拓/奶牛云/sourcecode/ucowsapp/ucowsapp/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
8 verbose lifecycle [email protected]~prebuild: CWD: /Users/crifan/dev/dev_root/daryun/Projects/奥拓/奶牛云/sourcecode/ucowsapp/ucowsapp
9 silly lifecycle [email protected]~prebuild: Args: [ ‘-c’, ‘mkdirp build && ncp src/assets build/assets’ ]
10 silly lifecycle [email protected]~prebuild: Returned: code: 0  signal: null
11 info lifecycle [email protected]~build: [email protected]
12 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
13 verbose lifecycle [email protected]~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/crifan/dev/dev_root/daryun/Projects/奥拓/奶牛云/sourcecode/ucowsapp/ucowsapp/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
14 verbose lifecycle [email protected]~build: CWD: /Users/crifan/dev/dev_root/daryun/Projects/奥拓/奶牛云/sourcecode/ucowsapp/ucowsapp
15 silly lifecycle [email protected]~build: Args: [ ‘-c’, ‘cross-env NODE_ENV=production webpack -p –progress’ ]
16 silly lifecycle [email protected]~build: Returned: code: 2  signal: null
17 info lifecycle [email protected]~build: Failed to exec build script
18 verbose stack Error: [email protected] build: `cross-env NODE_ENV=production webpack -p –progress`
18 verbose stack Exit status 2
18 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
18 verbose stack     at emitTwo (events.js:125:13)
18 verbose stack     at EventEmitter.emit (events.js:213:7)
18 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
18 verbose stack     at emitTwo (events.js:125:13)
18 verbose stack     at ChildProcess.emit (events.js:213:7)
18 verbose stack     at maybeClose (internal/child_process.js:887:16)
18 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
19 verbose pkgid [email protected]
20 verbose cwd /Users/crifan/dev/dev_root/daryun/Projects/奥拓/奶牛云/sourcecode/ucowsapp/ucowsapp
21 verbose Darwin 16.6.0
22 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
23 verbose node v8.0.0
24 verbose npm  v5.0.0
25 error code ELIFECYCLE
26 error errno 2
27 error [email protected] build: `cross-env NODE_ENV=production webpack -p –progress`
27 error Exit status 2
28 error Failed at the [email protected] build script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 2, true ]

倒是也没说是和上面那个库react-mobile-datepicker有关系

但是还是觉得有影响:

因为还存在一个:

react-mobile-datepicker.min.js

然后也去看了看:

node_modules/react-mobile-datepicker/package.json

  "_id": "[email protected]",
  "_inBundle": false,
  "_integrity": "sha1-+eADqoAI4yJr5tnAyjc6qP8fFPM=",
  "_location": "/react-mobile-datepicker",
  "main": "./dist/react-mobile-datepicker.js",
  "minified:main": "dist/react-mobile-datepicker.min.js",
  "name": "react-mobile-datepicker",

-》

估计这么直接修改xxx.js

会导致文件的integrity失效

所以导致npm run build的webpack打包失败

后来,在通过源码npm run build正常执行,生成所需要的

react-mobile-datepicker.js

react-mobile-datepicker.min.js

之后:

【已解决】如何从项目react-mobile-datepicker的js源码编译并发布js库

此preact项目再去:

npm run build

就可以正常执行了

-》说明之前的确是由于破坏了库的完整性导致出错的。

转载请注明:在路上 » 【已解决】npm run build项目出错:npm ERR! code ELIFECYCLE errno 2

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.185 seconds, using 22.14MB memory