npm install and ng serve command not working despite having npm and proper path set up

1.2k Views Asked by At

I have all the required packages to run node and angular app. Everything was working fine and out of nowhere all hell broke loose. Now, when I try to run npm install to install all the dependencies of the project, I get the following issue:

$ npm install
module.js:540
    throw err;
    ^
Error: Cannot find module 'C:\Program Files\Git\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

and when I try to create a new angular app, I get the following error:

ng new angular-app
module.js:540
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\Git\node_modules\@angular\cli\bin\ng'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Here's my PATH env variable:

C:\ProgramData\Oracle\Java\javapath;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\VG\Utils;
C:\Program Files (x86)\Lotus\Notes;
c:\oracle32\ora121\bin;
C:\Oracle64\ora121\bin;
C:\PROGRA~2\IBM\SQLLIB\BIN;
C:\PROGRA~2\IBM\SQLLIB\FUNCTION;
C:\PROGRA~2\IBM\SQLLIB\SAMPLES\REPL;
C:\PROGRA~2\ibm\gsk8\lib;
C:\Program Files\IBM\WebSphere MQ\Java\lib;
C:\Program Files (x86)\apache-maven-3.2.5\bin;
C:\Program Files (x86)\Java\jdk1.8.0\bin;
C:\Program Files\nodejs\;
C:\Program Files\Microsoft VS Code\bin;
C:\Program Files\Git\cmd;
C:\Users\UNBP\AppData\Local\Microsoft\WindowsApps;
C:\Users\UNBP\AppData\Roaming\npm
PATHEXT=.COM;
.EXE;
.BAT;
.CMD;
.VBS;
.VBE;
.JS;
.JSE;
.WSF;
.WSH;
.MSC

I have gone through all the posts here npm-cli.js not found when running npm, but that didn't solve my issue.

0

There are 0 best solutions below