Search code examples
javascriptangularnpmangular-clinpm-install

Why i cannot run ng command after successfully installing angular cli?


I have installed angular cli 1.5 from the command below:

C:\ANGULAR-WORKBENCH>npm install --global @angular/[email protected]

after completion of installation the following lines were displayed on terminal

+ @angular/[email protected]
added 115 packages and updated 1 package in 105.694s

Then I have tested if it was successfully installed by

C:\ANGULAR-WORKBENCH>ng -version

or

C:\ANGULAR-WORKBENCH>ng

In Both cases it displayed the error

module.js:538 throw err; ^
Error: Cannot find module '@angular-devkit/core' at Function.Module._resolveFilename (module.js:536:15) at Function.Module._load (module.js:466:25) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object. (C:\Users\User1\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\tree\virtual.js:10:16) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3)

Why this throws the error? How do i fix this issue?


Solution

  • You're using an old angular cli version. Try updating it:

    $ npm install -g @angular/cli@^1.6.5