Angular-cli: Can't run any command

Created on 18 Jan 2018  路  21Comments  路  Source: angular/angular-cli

Versions

node -v v8.9.4
npm -v 5.6.0

Repro steps


installed new angular cli

npm install -g @angular/cli

Output

C:\Users\xxx\AppData\Roaming\npm\ng -> C:\Users\xxx\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN @angular-devkit/[email protected] requires a peer of @angular-devkit/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @schematics/[email protected] requires a peer of @angular-devkit/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

Observed behavior

I get the same error no matter what ng command I run 
ng --version
ng new app

> module.js:540
>     throw err;
>     ^
> 
> Error: Cannot find module '@angular-devkit/core'
>     at Function.Module._resolveFilename (module.js:538:15)
>     at Function.Module._load (module.js:468:25)
>     at Module.require (module.js:587:17)
>     at require (internal/module.js:11:18)
>     at Object.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\tree\virtual.js:10:16)
>     at Module._compile (module.js:643:30)
>     at Object.Module._extensions..js (module.js:654:10)
>     at Module.load (module.js:556:32)
>     at tryModuleLoad (module.js:499:12)
>     at Function.Module._load (module.js:491:3)

Desired behavior

Mention any other details that might be useful (optional)

I tried to uninstall nodejs and npm and reinstall
Also remove angular and reinstall
npm uninstall -g angular/cli
npm cache clean
npm install -g @angular/cli

Most helpful comment

Yesterday we put out several releases for minor version that should address this: 1.4.10, 1.5.6, 1.6.5 and 1.7.0-beta.1. We also locked down the devkit dependencies on 1.4.10 and 1.5.6 so this does not happen again if you choose to stay on older versions.

Updating to the latest version within the minor you're using should fix this issue. For example, if you are on 1.5.1, updating to 1.5.6 should fix it.

You should not add @angular-devkit/core directly to your project, it will be installed as part of @angular/cli.

I'd like to remind everyone that you only have reproducible installs if you use a lockfile. Both NPM v5+ and Yarn support lockfiles. If your CI works one day but not the next and you did not change your code or package.json, it is likely because one of your dependencies had a bad release and you did not have a lockfile.

It is your responsibility as a library consumer to use lockfiles. No one wants to do a release with bugs but it sometimes happens, and the best we can do is to fix it as fast as possible with a new release. When you have a couple of thousand total dependencies it is only a matter of time until one of them has a bad release.

All 21 comments

Just ran into the same issue. 1.7.0 appears to have the same problem.

I just had the exact same problem. Whether this was intended or not, adding "@angular-devkit/core": "0.0.26" to my devDependencies solves the issue.

Looks like a dependency was removed somewhere. I worked around this by:

For local angular-cli: npm install @angular-devkit/core --save-dev
For global angular-cli: npm install -g @angular-devkit/core

Edit: As discussed below, you should perhaps not use --save-dev here.

@NickToony That works.
Thanks mate

@NickToony Tried your way, worked only in local cli

Hi. Sorry about that. We just released an emergency patch for the devkit and are working to release a patch for 1.4 and 1.5 that will fix this retroactively. After this we will re-release the CLI and the devkit.

Closing this as it will be fixed soon (in the next few hours).

Thanks for the quick response! We appreciate it.

So to clarify, the emergency patch is what's causing this error, 1.5.6 and 1.4.10 have not been patched (which is why they work right now) and once the patch is applied to 1.5 and 1.4, there will be a rerelease which will make 1.6.x and 1.7.x work?

Just run into this issue in the middle of a meetup, fun to have this live 鉁岋笍

Thanks for all support, installing @angular-devkit/core globally solved it.

Its failing on our build machine too with CLI version 1.6.3. But once I added the @angular-devkit/core to the dev dependencies of our project's package.json,it started working fine. Should we make this permanent and commit as part of our package.json file or the fix will be available so that we can continue using the existing one?

@hansl I have the same question about @saachinsiva's comment. Should we make @angular-devkit/core permanent and commit as part of our package.json?

Closed or not - my AWS CodeBuild and associated Pipeline is still broken. I tried the "global" fix suggested by @NickToony - but even after including that in my buildspec.yml, I'm still getting the same failure when it moves on to 'ng build'.

So - what is the preferred / optimal fix, while we're waiting for the emergency patch to propagate?

Thanks in advance!

Yesterday we put out several releases for minor version that should address this: 1.4.10, 1.5.6, 1.6.5 and 1.7.0-beta.1. We also locked down the devkit dependencies on 1.4.10 and 1.5.6 so this does not happen again if you choose to stay on older versions.

Updating to the latest version within the minor you're using should fix this issue. For example, if you are on 1.5.1, updating to 1.5.6 should fix it.

You should not add @angular-devkit/core directly to your project, it will be installed as part of @angular/cli.

I'd like to remind everyone that you only have reproducible installs if you use a lockfile. Both NPM v5+ and Yarn support lockfiles. If your CI works one day but not the next and you did not change your code or package.json, it is likely because one of your dependencies had a bad release and you did not have a lockfile.

It is your responsibility as a library consumer to use lockfiles. No one wants to do a release with bugs but it sometimes happens, and the best we can do is to fix it as fast as possible with a new release. When you have a couple of thousand total dependencies it is only a matter of time until one of them has a bad release.

@filipesilva I am using a lock file, and using a pinned version of angular cli 1.5.3

Still complains about @angular-devkit/core though

@dolanmiu you have to update to 1.5.6 like I say in my comment.

@dolanmiu This is how I resolve the issue on my side.

I removed the Node Modules

rm -rf node_modules/

Updated my package.json

BEFORE

  "devDependencies": {
    "@angular/cli": "1.6.4",
    "@angular/compiler-cli": "^5.1.0",
    "@angular/language-service": "^5.1.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }

AFTER

  "devDependencies": {
    "@angular/cli": "1.5.6",
    "@angular/compiler-cli": "^5.1.0",
    "@angular/language-service": "^5.1.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }

Install

npm i

I got it working yesterday with @NickToony solution but today I'm getting a different error
"You seem to not be depending on "@angular/core". This is an error."

I also deleted my node_modules and updated my package.json to 1.5.6 and ran npm install but still getting same error.

Upgrade of the CLI to 1.5.6 solves the issue with the devkit/core and devkit/schematics dependencies, but the issue with the dry-run error persists:

Error: dryRunSink.commit(...).ignoreElements(...).concat is not a function
dryRunSink.commit(...).ignoreElements(...).concat is not a function

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

@raffy-dev I had exactly the same problem. Just did a npm install -g @angular/core and then npm install, and everything went fine (maybe just the latter would suffice).

Uninstall node
Delete folder Angular folder from Appdata>>Roaming>>...

  • restart
  • npm i
  • npm -g update npm
  • npm uninstall -g @angular/cli angular/cli
  • npm cache clean
  • npm install -g @angular/cli

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hareeshav picture hareeshav  路  3Comments

rwillmer picture rwillmer  路  3Comments

donaldallen picture donaldallen  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments