0

I tried to install Angular CLI for learning Angular on Node 23 with npm install -g @angular/cli . The install seemed successful but post install while trying to run the ng version command I receive the following error.

An unhandled exception occurred: Cannot find module './package.json'
Require stack:
- C:\Users\sudha\AppData\Roaming\npm\node_modules\@angular\cli\src\noop.js
See "C:\Users\sudha\AppData\Local\Temp\ng-C0Y4aA\angular-errors.log" for further details.

Upon checking the files, I see that noop.js doesn't exist and in the log file mentioned above I see

[error] Error: Cannot find module './package.json'
Require stack:
- C:\Users\sudha\AppData\Roaming\npm\node_modules\@angular\cli\src\noop.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1259:15)
    at Function._load (node:internal/modules/cjs/loader:1085:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1350:12)
    at require (node:internal/modules/helpers:138:16)
    at VersionCommandModule.run (C:\Users\sudha\AppData\Roaming\npm\node_modules\@angular\cli\src\commands\version\cli.js:46:28)
    at VersionCommandModule.handler (C:\Users\sudha\AppData\Roaming\npm\node_modules\@angular\cli\src\command-builder\command-module.js:154:39)

Could you please suggest a way to resolve this issue?

4
  • 1
    Node 23 is not supported by Angular. Try Node 22 instead. angular.dev/reference/versions Commented Dec 3, 2024 at 7:58
  • Thank you, that helps. I didn't know that only LTS was supported Commented Dec 3, 2024 at 8:07
  • Did downgrading to Node 23 solve your issue? If yes, I will add an answer. However on my system, I could not reproduce this issue. Commented Dec 3, 2024 at 9:07
  • Yes, but now I've run into a different issue. The Angular CLI version is 19.0.2 but ng version reports Angular v16.2.12. How do I make it use version 19 like the CLI? Commented Dec 3, 2024 at 11:42

1 Answer 1

0

Angular only supports LTS versions of Node, see the docs. Try downgrading to Node v22.

As a rule of thumb, you should only use even-numbered (18, 20, 22, ...) Node major versions. Odd-numbered (19, 21, 23, ...) Node major versions never enter LTS and won't be supported by Angular. For more information, see the Node.js Releases docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.