75

I have created a angular project with Angular CLI: 1.6.3 Node: 9.4.0 OS: linux x64 version. But when want to run my angular app with command ng serve then fetch this error

Cannot find module '@angular-devkit/core'.

לבני מלכה
  • 15,925
  • 2
  • 23
  • 47
azmul hossain
  • 1,321
  • 2
  • 11
  • 15

13 Answers13

101

Try the following steps,

Step 1:

npm update -g @angular/cli

Step 2:

Edit your package.json changing the line

"@angular/cli": "1.6.0",

to

"@angular/cli": "^1.6.0",

STEP 3:

npm update

Refer the steps

Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • 8
    This helped me, +1 for that. But could you also add information on what these are solving? – Aragorn Jan 26 '18 at 15:27
  • I had to clear out node_modules, and do a fresh install using npm install, after updating the version to "^1.6.0". – Sudhir Mar 08 '18 at 14:01
  • 1
    I would give +1 if there'd be any explanation as to the cause of this. Freaking ridiculous to get compilation error on a fresh new project... – cah1r Mar 15 '18 at 17:19
  • im not sure what explanation to provide! the commands are self explanatory and it was a bug which is fixed afaik – Sajeetharan Mar 15 '18 at 17:24
28

try this out

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

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

try to update your angular cli

https://github.com/angular/angular-cli/issues/9307

inyee
  • 435
  • 4
  • 12
26

Step1: Edit your package.json changing the line

@angular/cli": "1.6.4"

to

@angular/cli": "^1.6.4"

Step2:

npm update -g @angular/cli 

Step3:

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

I was facing the exact same problem. These three did the tasks for me. You may like to see https://github.com/angular/angular-cli/issues/9307

Pieter
  • 895
  • 11
  • 22
krishna murari
  • 395
  • 2
  • 9
  • 2
    I used "npm update -g @angular/cli@latest" then "npm install --save-dev @angular/cli@latest", after that, the error disappear – IcyBrk Jan 27 '18 at 16:23
  • 1
    Sorry, mistakes made, the command I actually used was "npm install -g @angular/cli@latest" then "npm install --save-dev @angular/cli@latest" – IcyBrk Jan 27 '18 at 19:20
24

This can happen on different versions on angular-cli. You can install it manually with

 npm i -D @angular-devkit/core 

-D is shortcut to --save-dev

Or try the latest version of angular cli

npm install --save-dev @angular/cli@latest
alexKhymenko
  • 5,450
  • 23
  • 40
3

package.json, change to "@angular/cli": "^1.6.5",

 "devDependencies": {
"@angular/cli": "^1.6.5",
"@angular/compiler-cli": "^5.0.0",

Important, the version could be vary depends on what time.

You really should run

 npm update -g @angular/cli 

first, to get version, my is 1.6.5

What does the "^" do?

 ~1.0.2 means to install version 1.0.2 or the latest patch version such as 1.0.4. 

  ^1.0.2 means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.

last, run this

   npm update
hoogw
  • 4,982
  • 1
  • 37
  • 33
1

Just run:

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

In the project folder, to fix it.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
JMck
  • 21
  • 1
1

I did it by deleting package-lock.json and the node_modules folder. After that run "npm install" and start the application again.

0

You can do

First,

Delete the node_modules folder

Run npm install

And add devkit to your dev dependancies with npm i -D @angular-devkit/core

Tolotra Raharison
  • 3,034
  • 1
  • 10
  • 15
0

Step 1: delete package-lock.json Step 2: npm update -g @angular/cli Step 3: update @angular/cli new version in package.json Step 4: npm install

It worked for me.

0

I only installed my angular/cli using:
npm install -g @angular/cli@1.5.2
And I started getting this error.

Solution:
If your version is global and
If you don't mind the version of your angular/cli then type:
npm update -g @angular/cli

danilo
  • 7,680
  • 7
  • 43
  • 46
0

for me adding @angular-devkit/core solved the issue

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

I had this same error after updating some packages.

In my package.json I had the most current '@angular-devkit/core'

Using the standard solution to many problems:

rm -R node_modules/
npm install

And I updated the @angular/cli

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

and finally:

npm start
0

Only change "@angular/cli": "1.6.4", to "@angular/cli": "^1.6.4", and update npm with: npm update

Mojtaba Nava
  • 53
  • 1
  • 5