-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support type: module in Node.js 16.17.0+ and 18.6.0+ #23637
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
@lmiller1990 is this related? #23393 |
Yep same issue @emilyrohrbough |
a5db874
to
c219e2c
Compare
@@ -36,6 +36,9 @@ export CYPRESS_CACHE_FOLDER=/tmp/CYPRESS_CACHE_FOLDER/ | |||
export npm_config_cache=/tmp/npm_config_cache/ | |||
export npm_config_package_lock=false | |||
|
|||
mkdir /tmp/npm_config_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this, none of our existing binary system tests seem to actually install any node modules. These ones do, and without this line I get some random permission error when doing npm install in Docker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find, I remember running in to that permission error while setting this up and having NFC why it was happening.
Co-authored-by: Zach Bloomquist <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally with latest 16 + 18 and worked like a charm 🍀
@@ -36,6 +36,9 @@ export CYPRESS_CACHE_FOLDER=/tmp/CYPRESS_CACHE_FOLDER/ | |||
export npm_config_cache=/tmp/npm_config_cache/ | |||
export npm_config_package_lock=false | |||
|
|||
mkdir $npm_config_cache | |||
chown -R 1000:1000 $npm_config_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we do need the chown
, I think this would be safer, since the uid/gid aren't guaranteed to always be 1000:1000. But maybe this is wrong, considering what happened when this line was deleted, could be some trickery afoot.
chown -R 1000:1000 $npm_config_cache | |
chown -R $(id -u):$(id -g) $npm_config_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly enough this also is not working 🤔
Will ssh in and see what the output of id -u
and id -g
is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
circleci@ip-172-28-37-251:~$ id -u
1000
circleci@ip-172-28-37-251:~$ id -g
1000
Hmmmm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, chown -R $(id -u):$(id -g) $npm_config_cache
is just not valid code. Try running it. chown: missing operand after ‘1000:1000
.
Let's do...
uid=$(id -u)
gid=$(id -g)
chown -R $uid:$gui $npm_config_cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works for me on Linux in bash and zsh. You do have a slight typo, gid => gui
This script runs in the context of the Docker container too, not the main system... and id -u
and id -g
work, but by default we're running as root:
So now I'm even more confused why 1000:1000
is needed/works here, as we are running as root already.... 🤔 🤔 🤔
Co-authored-by: Zach Bloomquist <[email protected]>
To revert once a Cypress release is available with cypress-io/cypress#23637
ERR_LOADER_CHAIN_INCOMPLETE
in CI, works locally in a Dev Container #22795User facing changelog
Fix a bug where projects using Node.js 16.17+ and 18.6+ with
type: module
andcypress.config.ts
were not working with Cypress.Additional details
Projects with
type: module
using TypeScript (with acypress.config.ts
file) broke recently due to Node.js changing something on their end.This is the exact PR to Node.js that broke everything: nodejs/node#42623. It seems even the Node.js team wasn't fully across the scope of breakage that was introduced: nodejs/node#42623 (comment)
Anyway,
ts-node
made some fixes in response to handle it. We usets-node
internally. I just updated the version ofts-node
we ship to the latest, which has the relevant fixes. Everything seems okay now.To test this and avoid regressions, I added two new Docker images in the
cypress-docker-images
repo for Node.js 16.17.0 and 18.6.0.I then added some binary system tests to cover the Node.js versions we were not working on. I also created a branch to prove they were failing on develop (prior to this PR).
Steps to test
You could make a minimal reproduction locally like this: #22795 (comment). Then you'd build the binary and make sure it works. Or you can just see the above system tests that I added.
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?