29

I'm a little new to Angular, so apologies if this question has been asked many times. Certainly, I have found MANY github issues with similar symptoms, but no clear solution (or it's a problem that keeps coming back).

PROBLEM:

I installed whatever the latest version of Angular comes from npm:

npm install -g @angular/cli

When I run ng (with any options, even if just ng --version), I get the following error:

module.js:540
    throw err;
    ^

Error: Cannot find module '@angular-devkit/core'
    at Function.Module._resolveFilename (module.js:538:15)
    ...
    ...

APPARENT SOLUTION:

Installing @angular-devkit/core seems to fix the problem:

npm install -g @angular-devkit/core

... well, almost...

I then have to make sure I ALSO install the same devkit component for each application:

npm install --save @angular-devkit/core

QUESTIONS:

Is there a problem with Angular's packaging?

Do they deliberately leave out the devkit/core component, or just an accident with some versions?

OR, Could it be that I am doing something wrong?


SOFTWARE VERSIONS:

  • Angular CLI: 1.6.4
  • Node: 8.9.4
  • OS: linux x64
  • Angular: 5.2.1
4
  • 1
    github.com/angular/angular-cli/issues/9276 Commented Jan 18, 2018 at 22:17
  • @Jota.Toledo, thanks, seems like it's a re-occurring issue, and that specific github issue you referenced seems to suggest it's a new regression... just my luck, the day I start a new Angular project is the day the devkit is broken! Commented Jan 18, 2018 at 22:20
  • Thank you for sharing the solution, it worked for me. Commented Jan 19, 2018 at 9:09
  • angular/cli should not be installed with -g flag. it will corrupt your npm and ruin everything above it's level Commented Jan 20, 2022 at 18:57

8 Answers 8

19

Actually, all you need is to add missing @angular-devkit/core. For some reason it's missing in the new ng new process.

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

Of course since this is broken in 1.6.0 version you should upgrade your global @angular/cli and also your local in the project. This would make more permanent fix. The latest version also fixes missing devkit core dependency:

npm i -g @angular/cli@latest
npm i --save-dev @angular/cli@latest
Sign up to request clarification or add additional context in comments.

Comments

7

just add "@angular-devkit/core": "0.0.28" under your dev dependency and it will work, or you can also execute : npm install @angular-devkit/core --save-dev

Comments

5

This error has occurred due to @angular-devkit/core version upgrade in the recent @angular/cli upgrade. Failing version is @angular-devkit/[email protected]. So the solution to this is

npm install @angular-devkit/[email protected] --save -dev

This is just a patch work until angular team fix this in the next release or so.

Comments

3

Okay, you have to update your @angular/cli to 1.6.5 npm install -g @angular/[email protected] and update it in your project to 1.6.5 (npm install -g @angular/[email protected] --save-dev)

Comments

0

There have been a few builds that have released similar issues from Angular 2-5, I have experienced the same thing with packaging (just a different package). This is an easy fix, you did it right by npm installing it.

Just make sure the Angular Github issues page is aware of this, if it's not already up. They usually get fixes out for package issues relatively quickly.

Comments

0
  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

This should solve the issue your getting.

Comments

0

I was able to fix this issue by following below steps.

  1. I upgraded node version to stable 8.11.2.
  2. Install angular-cli version 6.0.5

Above steps fixed the issue.

Comments

0

I'm also facing the same issue. But updating your node may fix this. Because my is working when fixed node version.

1 Comment

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review

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.