此命令只能在CLI项目中运行 [英] This command can only be run inside of a CLI project
问题描述
由于某些原因,如果我运行以下命令,我想使用Angular v5
,它会在我不想使用的angular 6
中构建一个应用程序.
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
上面的命令生成了package.json文件,我交换了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.
此命令只能在CLI项目中运行.
This command can only be run inside of a CLI project.
如何使用Angular v5将这个应用程序制作为angular CLI?
How do I make this app as angular CLI with Angular v5??
推荐答案
您可以全局npm install -g @angular/cli@1.7.4
降级cli
的版本.与此cli
一起,将在版本5上生成角度项目.
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.
或
如果您不想更改全局的angular/cli版本,则可以使用npx @angular/cli@1.7.4 new hello
创建一个新的Angular项目.
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
.
这篇关于此命令只能在CLI项目中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!