Package '@angular/cli' is not a dependency

久未见 提交于 2021-02-07 04:44:06

问题


I am getting the following error when I try to run the command

ng update @angular/cli @angular/core --allow-dirty

Repository is not clean.  Update changes will be mixed with pre-existing changes.
Using package manager: 'npm'
Collecting installed dependencies...
Found 28 dependencies.
Package '@angular/cli' is not a dependency.

回答1:


First commit all your changes to the repo and then try following commands.

npm i -g @angular/cli@8.0.0

and

ng update --all --force

Please read this issue on github




回答2:


In my case it was missing node_modules folder. Make sure to run npm i before updating.




回答3:


I ran into this same issue/error message because I had switched branches that were drastically different and not yet run npm install on the branch to get the current version installed which at this point was Angular 7. After that completed, I ran the following again to install the latest version; Angular 8:

ng update @angular/cli @angular/core

This time the error did not appear and the upgrade was a success. It appears that the upgrade process is looking for valid files to know what version it's updating from, and if there is a missing or empty node_modules folder, Angular can't tell what exactly is being updated and will throw this error. It makes sense because the CLI behaves differently based on the old version being upgraded and how many versions are being updated, so if it has nothing to read from for upgrading it can't continue.



来源:https://stackoverflow.com/questions/57751607/package-angular-cli-is-not-a-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!