如何在 Angular Cli 中生成 .angular-cli.json 文件? [英] How to generate .angular-cli.json file in Angular Cli?

查看:39
本文介绍了如何在 Angular Cli 中生成 .angular-cli.json 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 npm 单独安装了 Angular CLI 包:

I have installed Angular CLI package separately using npm:

npm install --save-dev @angular/cli@latest

当我尝试使用命令 cli 时出现错误:

When I try to use commands cli I get an error:

Unable to find any apps in `.angular-cli.json`.

如何为当前项目生成.angular-cli.json?

推荐答案

我在当前项目中遇到了同样的错误并且很困惑,因为我在一个终端中运行应用程序/ng serve,但是当我尝试时得到了这个从另一个终端生成一个组件..angular-cli.json 已经存在并且正确.那么是什么?

I got this same error in my current project and was confused because I'm running the application / ng serve in one terminal, but got this when I tried to generate a component from another terminal. .angular-cli.json was already there and correct. So what gives?

我意识到我使用了快捷方式来打开 VisualStudio Code 的内部终端——这将终端打开到 项目 * 的*根目录(与大多数 IDE 一样).除了包含 .angular-cli.json 文件的 Angular 应用程序文件夹之外,该项目还包含其他内容.我只需要 cd 到正确的文件夹并再次运行 ng g c 一切都很好.

I realized that I used the shortcut to open VisualStudio Code's internal terminal -- which opened the terminal to the *root of the project * (like most IDEs). The project contains other things in addition to the Angular application folder that has the .angular-cli.json file in question. I just had to cd to the right folder and run ng g c again and things were fine.

就我而言,这只是一个愚蠢的错误.我以为我会回来分享,以便让人们为这么简单的事情真正头疼.我看到 Shiva 实际上已经在上面提到了这一点,但我想我会提供更多细节,以免被忽视.

In my case it was just a silly error. I thought I'd come back to share in order to save people a real headache for something so simple. I see that Shiva actually has mentioned this above, but I thought I would give a bit more detail so it doesn't get overlooked.

这篇关于如何在 Angular Cli 中生成 .angular-cli.json 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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