angular-cli: Unable to find "@angular/cli" in devDependencies

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0 node: 7.7.3 os: linux x64

Repro steps.

sudo yarn global upgrade @angular/cli

sudo yarn global remove @angular/cli sudo yarn global add @angular/cli

Run any ng command

The log given by the failure.

Unable to find "@angular/cli" in devDependencies.

Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"

Desired functionality.

ng command runs without issues.

Mention any other details that might be useful.

I am not sure this is related, but all new Angular apps I create using the CLI appear in the Home directory instead of the directory the command was run in.

About this issue

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

Most upvoted comments

It appears this was caused by having a node_modules folder and package.json file in the home directory, probably caused by doing an incorrect npm install command in the past.

I got it, in my case I had to delete package.json which I create earlier in application folder.

I got the same issue, this was after updating my angular cli on my project folder.

I had the same issue following steps helped me to resolve it,

  1. Update package json from “angular-cli”: “anything” to@angular/cli”: “1.0.4”

  2. Deleted node_modules and installed node modules again with npm install

  3. Change angular-cli.json for from “environments”: { “source”: “environments/environment.ts” “dev”: “environments/environment.ts”, “prod”: “environments/environment.prod.ts” } to “environmentSource”: “environments/environment.ts”, “environments”: { “dev”: “environments/environment.ts”, “prod”: “environments/environment.prod.ts” }

I’m going to keep this open actually, we shouldn’t check that root package.json really.

I have a monorepo with following structure:

root
|-packages
| |-angular-package1\
| |-angular-package2\
| ...
|-lerna.json
|-package.json

I am facing the following problem while ng new myapp --routing --directory packages/myapp. If I don’t include "@angular/cli": "^1.7.3" in devDependencies it complaints about Unable to find "@angular/cli" in devDependencies., and when I do, it tells me You cannot use the new command inside an Angular CLI project.. 🙁

As otonielguajardo mentioned, this happens when package.json exists in the directory where ‘ng new-app-name’ is run, as when creating a front-end for a server-side node app. To resolve this, I ran the command in a separate directory, then moved the created folder under my original app folder.

This happens to me only if a package.json already exists in same directory where running “ng new app-name”, in my case the package.json I use for my server side node app.