angular-cli: Error: Cannot find module '@angular-devkit/core' - after clean install

Versions


    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.6.4
Node: 6.11.0
OS: win32 x64
Angular: _(yup, I don't see it, but I install it 2 days ago)_
...

Repro steps

  • ng new e-commerce-with-tut-ng4
  • cd e-commerce-with-tut-ng-4
  • ng serve (to test if works)

Observed behavior

After that I’ve got this ->

C:\Users\TheTanadu\Desktop\codetemp\e-commerce-with-tut-ng4>ng serve
module.js:471
    throw err;
    ^

Error: Cannot find module '@angular-devkit/core'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\TheTanadu\Desktop\codetemp\e-commerce-with-tut-ng4\node_modules\@angular-devkit\schematics\src\tree\virtual.js:10:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

After all I came here but when I wanted to use ng --version in this path I’ve got same error like that what is up and I had to go cd … and then use ng -v

Desired behavior

I wanted to see local server

Mention any other details that might be useful (optional)

Windows 10

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 203
  • Comments: 114 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I struggled with the same problem just a minute ago. My project was generated using the v 1.6.0 of angular-cli.

  1. npm update -g @angular/cli
  2. editing my package.json changing the line “@angular/cli”: “1.6.0”, to “@angular/cli”: “^1.6.0”,
  3. npm update did the trick.

Only need run 👍 : npm i -D @angular-devkit/core

gosh thank you @LarsMengel 😄 That did it.

@jadeite100: Check out this link.

Excerpt:

So if you see ~1.0.2 it means to install version 1.0.2 or the latest patch version such as 1.0.4. If you see ^1.0.2 it means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.

Solved by updating to 1.6.5

I am using angular 1.6.5 for cli. In the examples from angular documentation: https://angular.io/tutorial/toh-pt6

In my package.json I change

original:

@angular/cli”: “1.5.0”,

new:

@angular/cli”: “^1.5.0”,

What does the “^” do exactly?

this is correct solution

npm install @angular-devkit/core --save-dev

https://github.com/angular/devkit/issues/256

npm i npm@latest -g

I think the correct way is to add the following to the dev-deps: "@angular-devkit/build-angular": "^0.6.1",

Or execute: npm install --save-dev @angular-devkit/build-angular

i got this error when i wanted to use my global ng‍‍‍ and create new angular project, this solved my problem: sudo npm i -g @angular-devkit/core

An update to version 1.6.5 seems to fix the issue npm update -g @angular/cli

Angular CLI: 1.6.5 Node: 6.11.3 OS: win32 x64 Angular: 5.2.1 … animations, common, compiler, compiler-cli, core, forms … http, language-service, platform-browser … platform-browser-dynamic, router

@angular/cdk: 5.1.0 @angular/cli: 1.6.5 @angular/material: 5.1.0 @angular-devkit/build-optimizer: 0.0.41 @angular-devkit/core: 0.0.28 @angular-devkit/schematics: 0.0.51 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.9.5 @schematics/angular: 0.1.16 typescript: 2.5.3 webpack: 3.10.0

The same with my 1.5.2 version.

I have the same issue with version 1.6.4. @LarsMengle this works because latest patch version is used 1.6.5. My problem is that 1.6.5 increased the prod build from 9minutes to 30 minutes

ha, ty guys… kept following all the comments and tada some magic happens and it is fixed now…

I did npm install @angular-devkit/core also added them to package json manually "@angular-devkit/core": "0.4.8", and did npm update

Hang on now. So obviously, updating angular-cli fixes the issue, but it appears that 1.5.0 to 1.6.4 suffered this problem. How did so many versions get released that wouldn’t even ng serve?

Thanks @LarsMengel I had to re-run npm install and problem solved. The reason being i was getting error “Your global Angular CLI version is greater than your local” while running npm update.

For Angular 6 you need to install/update @angular/cli, @angular-devkit/build-angular, @angular/compiler, and @angular/compiler-cli.

npm i --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli

Running npm update after is probably another good idea.

Having an old project (e.g. 1.5.4):

npm install

Folder node_modules/@angular-devkit/core is there

npm install @angular/cli

Folder node_modules/@angular-devkit/core is gone! 😕

Now ng update @angular/cli has no chance at all and will fail:

ng update @angular/cli
module.js:557
    throw err;
    ^

Error: Cannot find module '@angular-devkit/core'

Simplest possible solution. Do this AGAIN:

npm install @angular/cli

Folder node_modules/@angular-devkit/core is there again! 👍

Now ng update @angular/cli will work as expected.

@LarsMengel Great. Did the trick. Thanks man

I had the same Problem. I solved by below command npm update -g @angular/cli

@mehany No update necassary, cause ‘^’ will take the newest version anyway.

I can verify the solution still works, had the same problem this moring 👍

npm install --save-dev @angular/cli@latest

fixed the issue for me.

I have this issue today and updated my package.json to 1.6.8 and everything work’s fine.

@tienthanhjlw fixed for me too, I am using v1.6.3

Seems so. I suspect for some reasons “angular-devkit/core” hasn´t been downloaded during the “ng new” process. Updating all the packages did the trick. Would be interesting to know the reason.

@FatemeFazli Yeah that is exactly what I did, all the other solutions did not work for me.

@tienthanhjlw Thank you, saved my day. For me what worked was the same with the global option. So ng new would work.

npm i -g @angular-devkit/core