此命令只能在CLI项目中运行 [英] This command can only be run inside of a CLI project

查看:58
本文介绍了此命令只能在CLI项目中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,如果我运行以下命令,我想使用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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆