-
Notifications
You must be signed in to change notification settings - Fork 971
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
Set Node to v20 #6055
Set Node to v20 #6055
Conversation
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.
Looking at this PR it is missing an update to the CI files which are under .github/workflows
To that point I also think it would be preferable to use the engine field in package.json over .npmrc files. An alternative would be to define a top level .node-version file. Our CI could be made to consume both of these to ensure they are always in sync.
19fcdd7
to
63fccea
Compare
@VIKTORVAV99 I updated the CI files and decided to go with updating both the package.json file and also adding in .node-version files, so I can use it with fnm. I have two possible suggestions now:
Let me know what you think about that |
The built in cache only caches the pnpm cache which is slower than what we do here (cache the entire node folder and skip install) this has been tested and the current method resulted in the lowest CI time. You can try and change how the workflows work if you wish but I'm not sure they work that way. Was a while since I took a look at them though. |
63fccea
to
94c553e
Compare
@VIKTORVAV99 Ok, understood. I think my second suggestion (creating a The CI workflow failed on October 27 because two jobs failed. The Cypress job failed because the The Deploy Preview job also failed, with the error message "secret CLOUDFLARE_API_TOKEN is required, but not provided while calling". I don't know why the secret would not have been present at the CI run, maybe some Github permission setting that needs to be changed? Could you please look into it if it occurs again? |
@VIKTORVAV99 Yesterday, the Cypress CI job failed with the following error:
Basically, the installation of Cypress is one of those cases where caching node_modules is not enough. I looked at the recommendations from Cypress and also their examples to add more steps to the Cypress jobs. On the positive side, if all these changes work, they should make the Cypress jobs noticeably faster than before this PR, once the cache has been set. I also added a comment on the register-tsNodeESM.js file, something I had meant to do but kept forgetting. |
@VIKTORVAV99 I believe this PR should be okay to merge now. The only CI job that is failing is the Preview one, because my fork branch cannot have access to Github Secrets. |
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.
LGTM! Thanks for taking care of this!
* fix: set front-end to Node v20, fix use of ts-node * fix: Cypress CI workflow now uses required Node version and dependencies cache * fix: Add install=false for cypress-io/github-action * fix: in CI workflow, install and cache Cypress binary * docs: add JSDoc description to register-tsNodeESM.js file
Issue
Closes #5984
(Although a wiki update will still be required once this is merged)
Description
I'm new to this project and decided to take on this issue because I ran into it when I first setup this project. Sorry ahead of time for this long message, but I figure you'd appreciate seeing my reasoning.
First, I made .npmrc file changes, adding in the setting use-node-version. This will make PNPM use Node v20.9.0 when running any package.json script. PNPM will actually download that version of Node if it does not detect it on the developer's machine. I tried to use a less specific version (e.g
use-node-version=20
), but then PNPM complained that this was not a correct format. An alternative approach would be to use the popular tool [NVM}(https://github.com/nvm-sh/nvm) along with adding new .nvmrc files, which does allow only specifying a major version. Also, I don't know if this is going to require changes or not in your CI environment.Second, the issue we were seeing with running the project with Node 20 was simply caused by the fact that ts-node has not been updated since July 2022, and therefore it does not have a targeted configuration for running with ESM mode in Node 20. Indeed, there is a long-standing open issue about this.
In the long issue thread, you will see that most people tackle this issue by running their script with
node --experimental-loader=ts-node/esm
(ornode --loader=ts-node/esm
, which is the same thing). However, this approach is discouraged in the Node 20 CLI documentation. It also has the unpleasant side-effect of displaying a long warning in the terminal, which can only be disabled by turning off all warnings from Node. The good thing is that the warning message output the code that is now in the new file web/scripts/register-tsNodeESM.js, a module resolution hook, which allows us to use the preferred--import
flag.Note that there is a ts-node PR which will add a similar hook to ts-node, hopefully in an upcoming release. Also, after no releases in a long time, ts-node had a beta released last week for a new major version. So this script I added may not be needed for too long, but in the meanwhile I think it's good that we upgrade to the latest Node LTS.
Double check
pnpx prettier --write .
andpoetry run format
to format my changes.