fix: support type: module in Node.js 16.17.0+ and 18.6.0+#23637
fix: support type: module in Node.js 16.17.0+ and 18.6.0+#23637lmiller1990 merged 8 commits intodevelopfrom
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
| 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.
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.
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 <git@chary.us>
ZachJW34
left a comment
There was a problem hiding this comment.
Tested locally with latest 16 + 18 and worked like a charm 🍀
| export npm_config_package_lock=false | ||
|
|
||
| mkdir $npm_config_cache | ||
| chown -R 1000:1000 $npm_config_cache |
There was a problem hiding this comment.
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.
I will try this!
There was a problem hiding this comment.
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.
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.
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_cacheThere was a problem hiding this comment.
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 <git@chary.us>
To revert once a Cypress release is available with cypress-io/cypress#23637
ERR_LOADER_CHAIN_INCOMPLETEin 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: moduleandcypress.config.tswere not working with Cypress.Additional details
Projects with
type: moduleusing TypeScript (with acypress.config.tsfile) 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-nodemade some fixes in response to handle it. We usets-nodeinternally. I just updated the version ofts-nodewe 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-imagesrepo 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?