This command can only be run inside of a CLI project

。_饼干妹妹 提交于 2019-12-12 19:24:46

问题


For some reasons, I want to use Angular v5 if I run the below command,it builds an app in angular 6 which I don't want.

ng new hello //this creates angular app in the latest version

I ran the command in the below order

npm init //generated package.json

The above command generated package.json file, I swapped the content of package.json file.

https://jsoneditoronline.org/?id=5acc3c072e164c4a8235152516e44f54

npm install //installed all the node modules

now when I run command to generate the angular component (or any angular enitity) it throws the below error.

This command can only be run inside of a CLI project.

How do I make this app as angular CLI with Angular v5??


回答1:


You can degrade version of cli globally npm install -g @angular/cli@1.7.4. With this cli will generate angular project on version 5.

Or

If you don't want to change your global angular/cli version you can create a new Angular project using npx @angular/cli@1.7.4 new hello.




回答2:


Don't degrade version as in Angular 4+ we don't use new to create new component Instead use generate command to make new component

ng generate component your_Comp_Name



来源:https://stackoverflow.com/questions/50929594/this-command-can-only-be-run-inside-of-a-cli-project

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