question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress exits with "npm ERR! code ELIFECYCLE" after headless run

See original GitHub issue

I have a list of scripts: image

When I run npm run cy:test and during this run I have one of the tests failed, my npm script exits with this error:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! integration-tests@1.0.0 cy:test: `npm run prereport && npx cypress run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the integration-tests@1.0.0 cy:test 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!     C:\Users\yural\AppData\Roaming\npm-cache\_logs\2021-06-11T13_10_32_602Z-debug.log

Screenshot of the run with failed test: image

Screenshot of the run with successful test: image

In both cases prereport script will have its job done (erases result folder) and cypress run will execute all specs, however if during the run some tests failed it will exist with NPM error. I would not mind that in this case, because I have all my scripts done despite that error. HOWEVER, I also have another script which is called cy:run, in this case I want my mochawesome reports be generated in the end of the run, BUT if, again, one of the tests failed during the run npm WON’T run my junit:mr and mocha:mr. ALSO want to mention that if I run npx cypress run ALONE, it will exit without any NPM error in the end even with having all tests failed.

Here is my log of the error with npm run cy:test:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\Programs\\Nodejs\\node.exe',
1 verbose cli   'D:\\Programs\\Nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'cy:test'
1 verbose cli ]
2 info using npm@6.14.6
3 info using node@v12.18.4
4 verbose run-script [ 'precy:test', 'cy:test', 'postcy:test' ]
5 info lifecycle integration-tests@1.0.0~precy:test: integration-tests@1.0.0
6 info lifecycle integration-tests@1.0.0~cy:test: integration-tests@1.0.0
7 verbose lifecycle integration-tests@1.0.0~cy:test: unsafe-perm in lifecycle true
8 verbose lifecycle integration-tests@1.0.0~cy:test: PATH: D:\Programs\Nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Programs\OpenServer\OpenServer\domains\dipp\integration-tests\node_modules\.bin;D:\Programs\Git\mingw64\bin;D:\Programs\Git\usr\bin;C:\Users\yural\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\IBM\SPSS\Statistics\23\JRE\bin;C:\Program Files (x86)\QuickTime\QTSystem;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;D:\Programs\codeopenio\command;D:\Programs\Git\cmd;C:\Program Files\dotnet;D:\Programs\Nodejs;C:\Program Files\Calibre2;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\yural\AppData\Local\Programs\Python\Python38-32\Scripts;C:\Users\yural\AppData\Local\Programs\Python\Python38-32;C:\Users\yural\AppData\Local\Microsoft\WindowsApps;D:\Programs\Microsoft VS Code\bin;C:\Users\yural\AppData\Roaming\npm
9 verbose lifecycle integration-tests@1.0.0~cy:test: CWD: D:\Programs\OpenServer\OpenServer\domains\dipp\integration-tests
10 silly lifecycle integration-tests@1.0.0~cy:test: Args: [ '/d /s /c', 'npm run prereport && npx cypress run' ]
11 silly lifecycle integration-tests@1.0.0~cy:test: Returned: code: 1  signal: null
12 info lifecycle integration-tests@1.0.0~cy:test: Failed to exec cy:test script
13 verbose stack Error: integration-tests@1.0.0 cy:test: `npm run prereport && npx cypress run`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (D:\Programs\Nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (D:\Programs\Nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid integration-tests@1.0.0
15 verbose cwd D:\Programs\OpenServer\OpenServer\domains\dipp\integration-tests
16 verbose Windows_NT 10.0.19043
17 verbose argv "D:\\Programs\\Nodejs\\node.exe" "D:\\Programs\\Nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "cy:test"
18 verbose node v12.18.4
19 verbose npm  v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error integration-tests@1.0.0 cy:test: `npm run prereport && npx cypress run`
22 error Exit status 1
23 error Failed at the integration-tests@1.0.0 cy:test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

P.S. I have tried to clear npm cache, delete node_modules, delete lock.json file and run npm i command dozens of times, I even tried different cypress versions and other related plugins and packages, reboot my PC and all magic I had, ZERO result.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
oh-jestin-sebastiancommented, Sep 15, 2021

@yasinitskyi I see that you closed this issue. I am also facing the same issue. Were you able to find the root cause and a solution?

0reactions
jhonjhon95commented, Sep 23, 2022

o erro persiste, alguma solução ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

cypress-io/cypress - Gitter
After I do npm ci in the Dockerfile, I verify the crypress binary, so I don't understand why it says node_modules missing when...
Read more >
How to solve npm error "npm ERR! code ELIFECYCLE"
Step 1: $ npm cache clean --force. Step 2: Delete node_modules by $ rm -rf node_modules ( rmdir /S /Q node_modules in windows)...
Read more >
Command Line - Cypress Documentation
Read how we typically organize and execute npm scripts in the blog post How I Organize my npm ... If there are no...
Read more >
For those, who have experienced an error npm ERR! code ...
When cypress scenarios are getting failed, it triggers an error code that NPM treats as an unexpected error in the test script which...
Read more >
JS TDD E2E - textbook
cypress /integration/e2e.test.js $ npm run e2e > rps-e2e@0.1.0 e2e ... run Cypress again. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR!...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found