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

查看:150
本文介绍了如何在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服务而感到困惑,但是当我尝试在从另一个终端生成组件. .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天全站免登陆