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

查看:18
本文介绍了此命令只能在 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

我按以下顺序运行命令

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=5acc3c072e164c425234c4a8234e>p>

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??

推荐答案

您可以全局降级 cli 的版本 npm install -g @angular/cli@1.7.4.使用此 cli 将在版本 5 上生成 angular 项目.

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天全站免登陆