How to resolve the error "ERR! code ELIFECYCLE"?

Viewed 11853

I am using the Jest to perform the unit testing.

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

All the test has been passed and ran but got an error as below

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

I tried the below command from the google search, however, it is not working

npm cache clean --force

rm -rf node_modules

npm install

error from logs

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 ]
3 Answers
Snapshots: 2 obsolete, 5 passed, 5 total

obsolete - are the cause of the error, after their removal, the error is gone.

Delete the snapshots and rerun the test everything should work fine

Reference - https://github.com/facebook/jest/issues/9324

I tried to solve this problem with this way:

rm -rf node_modules && rm ./package-lock.json && npm install

After that restart your machine and its working perfectly.

I faced the similar issue in wdio cucumber setup with node 14, and npm 6. The tests were executed correctly but this error surfaced in every run.

error code ELIFECYCLE 
error Exit status 1

upgraded to the latest node 16.17.0 and npm 8.18 -- error gone. The error could be due to non compatible packages

Related