如何解决错误“ERR!code 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

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


npm cache clean --force


rm -rf node_modules


npm install


德玛西亚99
浏览 260回答 3
3回答

收到一只叮咚

Snapshots: 2 obsolete, 5 passed, 5 total已过时 - 是错误的原因,在删除它们后,错误就消失了。删除快照并重新运行测试一切正常参考 - https://github.com/facebook/jest/issues/9324

至尊宝的传说

我在使用节点 14 和 npm 6 的 wdio 黄瓜设置中遇到了类似的问题。测试执行正确,但每次运行都会出现此错误。error code ELIFECYCLE  error Exit status 1升级到最新的节点 16.17.0 和 npm 8.18——错误消失了。该错误可能是由于不兼容的包

哈士奇WWW

我试图用这种方式解决这个问题:rm -rf node_modules && rm ./package-lock.json && npm install之后重新启动您的机器并正常工作。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript