如何解决错误ERR!代码ELIFECYCLE

问题描述

我正在使用Jest进行单元测试。

"jest": "^26.4.2","jest-preset-angular": "^8.3.1"

所有测试均已通过并运行,但出现以下错误

Test Suites: 20 passed,20 total
Tests:       26 passed,26 total
Snapshots:   2 obsolete,5 passed,5 total
Time:        92.961 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! idp@0.0.0 test:app: `jest --config ./jest.app.config.js --no-cache`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the idp@0.0.0 test:app 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/macbook/.npm/_logs/2020-09-15T09_19_42_790Z-debug.log

我从Google搜索中尝试了以下命令,但是它不起作用

npm cache clean --force

rm -rf node_modules

npm install

日志错误

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node','/usr/local/bin/npm','run','test:app' ]
2 info using npm@6.14.8
3 info using node@v14.5.0
4 verbose run-script [ 'pretest:app','test:app','posttest:app' ]
5 info lifecycle idp@0.0.0~pretest:app: idp@0.0.0
6 info lifecycle idp@0.0.0~test:app: idp@0.0.0
7 verbose lifecycle idp@0.0.0~test:app: unsafe-perm in lifecycle true
8 verbose lifecycle idp@0.0.0~test:app: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp/node_modules/.bin:/usr/local/opt/helm@2/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
9 verbose lifecycle idp@0.0.0~test:app: CWD: /Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp
10 silly lifecycle idp@0.0.0~test:app: Args: [ '-c','jest --config ./jest.app.config.js --no-cache' ]
11 silly lifecycle idp@0.0.0~test:app: Returned: code: 1  signal: null
12 info lifecycle idp@0.0.0~test:app: Failed to exec test:app script
13 verbose stack Error: idp@0.0.0 test:app: `jest --config ./jest.app.config.js --no-cache`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
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 ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1051:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid idp@0.0.0
15 verbose cwd /Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp
16 verbose Darwin 19.6.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:app"
18 verbose node v14.5.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error idp@0.0.0 test:app: `jest --config ./jest.app.config.js --no-cache`
22 error Exit status 1
23 error Failed at the idp@0.0.0 test:app script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1,true ]

解决方法

我试图用这种方式解决这个问题:

tqdm

之后,重新启动计算机,使其工作正常。

,
Snapshots: 2 obsolete,5 passed,5 total

已过时-是导致错误的原因,将其删除后,错误就消失了。

删除快照并重新运行测试,一切应该正常运行

参考-https://github.com/facebook/jest/issues/9324