cypress: Unable to start Cypress with ELECTRON_RUN_AS_NODE=1
Current behavior
If you set env with ELECTRON_RUN_AS_NODE=1, with MacOS, you are not able to start the Cypress with
ELECTRON_RUN_AS_NODE=1 npx cypress run
You’ll get error:
Error: Cannot find module '/Users/<username>/Library/Caches/Cypress/10.6.0/Cypress.app/Contents/MacOS/Contents/Resources/app/index.js'
Checking the code, it seems that here is where it went wrong: https://github.com/cypress-io/cypress/blob/b615e8ac30b681b4dc8485afe9814ff453da1fbf/cli/lib/exec/spawn.js#L175
The correct path, at least for Mac, should be:
path.join(state.getBinaryPkgPath(path.join(executable, '..', '..', '..')), '..', 'index.js');
Desired behavior
Cypress should start correctly
Test code to reproduce
Try run with
ELECTRON_RUN_AS_NODE=1 npx cypress run
Cypress Version
10.6.0
Node version
16.0
Operating System
macOS
Debug Logs
No response
Other
Cypress 10.7.0 (latest) also has this problem
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 20 (12 by maintainers)
I can get around the issue mentioned by @lsantos10 ^^ if I run
npx cypress verifyin CI first withoutELECTRON_RUN_AS_NODE: 1, however it still doesn’t work.After running
npx cypress verifyfirst, I then see a different error message on Ubuntu22.04/ Cypress12.13.0/ Node.js18.16.0“Error: Cannot find module ‘./start-cypress’”
Edit: Still reproducible on Cypress
13.4.0with Node.js18.18.2.See repo https://github.com/MikeMcC399/cy-xvfb-test
Workflow chrome_as_node.yml
I got the same problem on MacOS. It’s different on Linux:
Seems similar to #17412.
Looking at the docs…
To figure out the priority on fixing this bug - do you have a specific use case in mind where you need to launch with
ELECTRON_RUN_AS_NODE?