0

Using npm, I have installed angular-cli globally, with the command npm install -g @angular/cli.

After installing it succesfully, every command including just ng -v, returns the same error:

Error: Cannot find module '@angular-devkit/core'
Require stack:
- C:\Users\btngtk\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\btngtk\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)?[39m
at Function.Module._load (internal/modules/cjs/loader.js:527:27)?[39m
at Module.require (internal/modules/cjs/loader.js:681:19)?[39m
at require (internal/modules/cjs/helpers.js:16:16)?[39m
    at Object.<anonymous> (C:\Users\btngtk\AppData\Roaming\npm\node_modules\?[4m@angular?[24m\cli\lib\init.js:13:16)
at Module._compile (internal/modules/cjs/loader.js:774:30)?[39m
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)?[39m
at Module.load (internal/modules/cjs/loader.js:641:32)?[39m
at Function.Module._load (internal/modules/cjs/loader.js:556:12)?[39m
at Module.require (internal/modules/cjs/loader.js:681:19)?[39m {
  code: ?[32m'MODULE_NOT_FOUND'?[39m,
  requireStack: [
    ?[32m'C:\\Users\\btngtk\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\lib\\init.js'?[39m,
    ?[32m'C:\\Users\\btngtk\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\bin\\ng'?[39m
  ]
}    
6
  • 3
    @angular-devkit is required by @angular/cli as dependency maybe something went wrong with npm install. Maybe try npm uninstall -g @angular/cli, then clear the npm cache with npm cache clean and then retry the installation. Commented Jun 26, 2019 at 12:13
  • I tried that several times, with npm uninstall -g @angular/cli and deleting physically npm and npm-cache directories Commented Jun 26, 2019 at 12:21
  • What's you node.js version? Commented Jun 26, 2019 at 12:26
  • The latest one, 12.4.0 , but prior to that I tried with the 10.16.0 with the same result. Commented Jun 26, 2019 at 12:41
  • Thx @youri, it works. It's just that I had to add --force when cleaning the cache. npm cache clean --force Commented Jul 3, 2019 at 13:45

1 Answer 1

2

@angular-devkit is required by @angular/cli as dependency maybe something went wrong with npm install.

So uninstall @angular/cli with:

npm uninstall -g @angular/cli

Then clear the npm cache with:

npm cache clean --force

And then retry the installation.

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.