ng version fails with error "Cannot find module ./package.json"

Discussão em 'Angular' iniciado por SBM, Dezembro 3, 2024.

  1. SBM

    SBM Guest

    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?

    Continue reading...

Compartilhe esta Página