由于某些原因,我想使用Angular v5
如果我运行以下命令,它会在 angular 6
中构建一个应用程序这是我不想要的。
ng new hello //this creates angular app in the latest version
我按以下顺序运行命令
npm init //generated package.json
上面的命令生成了package.json文件,我交换了package.json文件的内容。
https://jsoneditoronline.org/?id=5acc3c072e164c4a8235152516e44f54
npm install //installed all the node modules
现在当我运行命令来生成 Angular 分量(或任何 Angular 实体)时 它抛出以下错误。
This command can only be run inside of a CLI project.
如何使用 Angular v5 将此应用程序制作为 Angular CLI?
最佳答案
您可以降级 cli
的版本全局npm install -g @angular/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e5d52577e0f1009100a" rel="noreferrer noopener nofollow">[email protected]</a>
。有了这个cli
将在版本 5 上生成 Angular 项目。
或者
如果您不想更改全局 Angular/cli 版本,您可以使用 npx @angular/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9dfef1f4ddacb3aab3a9" rel="noreferrer noopener nofollow">[email protected]</a> new hello
创建一个新的 Angular 项目。 。
关于angular - 该命令只能在 CLI 项目内部运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50929594/