ng commands hangs on node version v20.12.2
EdvinOlofsson opened this issue · 9 comments
Command
version
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Hello!
Using node version v18.20.2 works.
But updating node to LTS v20.12.2 causes the ng command to hang. (source <(ng completion script) also hangs)
I use nvm to manage node versions.
Going from my setup that works (listed below) I only change node version in the terminal using 'nvm use v20.12.2'
Then If I run 'ng version' it hangs indefinitely
This is the setup I have that WORKS:
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / | | | | |/ _
| '__| | | | | | |
/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
Angular CLI: 17.3.6
Node: 18.20.2
Package Manager: yarn 1.22.19
OS: linux x64
Angular: undefined
...
Package Version
@angular-devkit/architect 0.1703.6 (cli-only)
@angular-devkit/core 17.3.6 (cli-only)
@angular-devkit/schematics 17.3.6 (cli-only)
@schematics/angular 17.3.6 (cli-only)
typescript 5.4.3
Minimal Reproduction
Install latest version of ng cli using:
$ npm install -g @angular/cli
Make sure node is version >18
$ node -v
v20.12.2
run any ng command:
$ ng version
Exception or Error
No response
Your Environment
Unable to produce this as ng version command hangs on node v20
But as stated previously, downgrading node to v18 solves the issue.
Angular CLI: 17.3.6
Node: 18.20.2
Package Manager: yarn 1.22.19
OS: linux x64
Angular: undefined
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1703.6 (cli-only)
@angular-devkit/core 17.3.6 (cli-only)
@angular-devkit/schematics 17.3.6 (cli-only)
@schematics/angular 17.3.6 (cli-only)
typescript 5.4.3
Anything else relevant?
No response
@EdvinOlofsson, I am unable to replicate this. Have you tried to re-install Node.js?
Hello! What a quick reply, amazing.
I tried reinstalling nodejs using nvm
$ nvm uninstall v20.12.2
$ nvm install v20.12.2
$ nvm use v20.12.2
$ ng version
command still hangs
You can generate a CPU profile to see why it is hanging.
node --cpu-prof node_modules/.bin/ng version
Ok we are getting some where.
So I created a brand new hello-world example as per angular documentation.
$ npm install -g @angular/cli
$ ng new hello-world
$ node --cpu-prof node_modules/.bin/ng version
Angular CLI: 17.3.6
Node: 20.12.2
Package Manager: npm 10.5.0
OS: linux x64
Angular: 17.3.6
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.1703.6
@angular-devkit/build-angular 17.3.6
@angular-devkit/core 17.3.6
@angular-devkit/schematics 17.3.6
@schematics/angular 17.3.6
rxjs 7.8.1
typescript 5.4.5
zone.js 0.14.4
So it works with node v20 if I'm using the node_modules/.bin/ng file.
But it still hangs if I use the globally installed ng command.
$ which ng
/usr/bin/ng
But you where able to run ng new hello-world
which is the global installed command. So it's looks like only ng version
is hanging.
I am a bit surprised to see that which ng
return /usr/bin/ng
as typically with nvm
you'd have something like /usr/local/.../.nvm/versions/node/v20.12.2/bin/ng
Can you try to ran another ng
such as ng config
command outside of the workspace? and also generate a CPU profile for the global CLI by using
node --cpu-prof-dir="." --cpu-prof /usr/bin/ng version
Kindly provide the generated *.cpuprofile file located in the current working directory, which can aid in identifying the source of the issue.
Hello!
I'm sorry, I should have spesified I ran ng new hello-world with node v18.
That inturn created the hello-world project where I could execute ./node_modules/.bin/ng commands succesfully with node v20.
It seems that when ever I run the node_modules/.bin/ng everything works fine with any node version.
But running the global /usr/bin/ng failes on node v20 and runs succesfully on node v18."
Note that source <(ng completion script) fails using node v20 also. So I suppsect its only an issue in the globally installed ng.
CPU.20240426.122732.94486.0.001.cpuprofile
I'm not sure how much value this CPU profile will be as it is generated with the working ./node_modules/.bin/ng exectuable.
Trying to generate it using the global install results in this:
$ node --cpu-prof /usr/bin/ng version
/usr/bin/ng:2
Copyright (c) 2000 Yasuhiro Take take@debian.org
^
SyntaxError: Invalid or unexpected token
at internalCompileFunction (node:internal/vm:128:18)
at wrapSafe (node:internal/modules/cjs/loader:1280:20)
at Module._compile (node:internal/modules/cjs/loader:1332:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.12.2
$ nvm use 18
Now using node v18.20.2 (npm v10.5.0)
$ node --cpu-prof /usr/bin/ng version
/usr/bin/ng:2
Copyright (c) 2000 Yasuhiro Take take@debian.org
^
SyntaxError: Invalid or unexpected token
at internalCompileFunction (node:internal/vm:76:18)
at wrapSafe (node:internal/modules/cjs/loader:1283:20)
at Module._compile (node:internal/modules/cjs/loader:1328:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49
Node.js v18.20.2
I have tried to reinstall/update the global ng package before with out success.
But now I reinstalled it using
$ npm uninstall -g ng
$ npm uninstall -g @angular/cli
$ sudo rm /usr/bin/ng
$ npm install -g @angular/cli
$ which ng
/home/edvin/.nvm/versions/node/v20.12.2/bin/ng
And now ng version runs successfully using node v20!
Great!
I'm not sure exactly why still, something broken with how my node enviornment was setup with nvm I assume?
Thank you for helping me with this and your incredibly fast response times.
Appriciate it.
You can consider this matter resolved.
Glad to hear that you resolved the issue 😀
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.