Skip to content
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

Yarn fails to build Angular with recent Node.js versions #53334

Closed
johnnygerard opened this issue Dec 3, 2023 · 4 comments
Closed

Yarn fails to build Angular with recent Node.js versions #53334

johnnygerard opened this issue Dec 3, 2023 · 4 comments
Labels
area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing)
Milestone

Comments

@johnnygerard
Copy link
Contributor

johnnygerard commented Dec 3, 2023

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

Node.js v18.18.2 successfully builds but v18.19.0 and v20.9.0 both fail with the same error message.

To replicate the issue, run the following commands:

gh repo clone johnnygerard/angular
cd angular
yarn install
yarn build

Note that the Yarn build was done on my fork of Angular which is synced.
Last commit: acd6100

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

(main) $ yarn build
yarn run v1.22.19
$ ts-node --esm --project scripts/tsconfig.json scripts/build/build-packages-dist.mts
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".mts" for ~/test/angular_20_9_0/scripts/build/build-packages-dist.mts
    at new NodeError (node:internal/errors:406:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:142:36)
    at defaultLoad (node:internal/modules/esm/load:120:20)
    at nextLoad (node:internal/modules/esm/hooks:833:28)
    at load (~/test/angular_20_9_0/node_modules/ts-node/dist/child/child-loader.js:19:122)
    at nextLoad (node:internal/modules/esm/hooks:833:28)
    at Hooks.load (node:internal/modules/esm/hooks:416:26)
    at MessagePort.handleMessage (node:internal/modules/esm/worker:168:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
(main) $ node --version
v20.9.0

Please provide the environment you discovered this bug in (run ng version)

OS: Ubuntu 22.04.3 LTS
Shell: GNU bash v5.1.16

Anything else?

No response

@JoostK
Copy link
Member

JoostK commented Dec 3, 2023

This is due to TypeStrong/ts-node#2094. The Angular repo has an .nvmrc file that requests Node 18.13.

@JoostK JoostK added the area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) label Dec 3, 2023
@ngbot ngbot bot added this to the needsTriage milestone Dec 3, 2023
@johnnygerard
Copy link
Contributor Author

johnnygerard commented Dec 3, 2023

Thanks, I didn't know about .nvmrc.

I followed the instructions from Building and Testing Angular which says:

Node.js, (version specified in the engines field of package.json) ...

The engines field currently specifies "node": "^18.13.0 || ^20.9.0".

It would be nice to mention this .nvmrc file somewhere in Building and Testing Angular.

@JoostK
Copy link
Member

JoostK commented Dec 3, 2023

I had forgotten about the engines range in package.json. The .nvmrc file is considered by Node version managers to automatically use the configured version, but I do agree that the engines specification in package.json is a better indication of what versions should be fine to use. Since this was a very recent Node release that broke ts-node's ESM loader, 18.20 is not, in fact, supported at the moment.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 18, 2024
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this issue Jan 23, 2024
rlmestre pushed a commit to rlmestre/angular that referenced this issue Jan 26, 2024
danieljancar pushed a commit to danieljancar/angular that referenced this issue Jan 26, 2024
amilamen pushed a commit to amilamen/angular that referenced this issue Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@JoostK @johnnygerard and others