50

I have installed Angular CLI package separately using npm:

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

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

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

How to generate .angular-cli.json for current project?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
POV
  • 11,293
  • 34
  • 107
  • 201
  • 1
    have you tried `ng new your_app` ? make sure you have install `@angular/cli@latest` globally as well. – Touqeer Shafi Jul 20 '17 at 07:21
  • 1
    I have installed project yet, I dont need new project – POV Jul 20 '17 at 07:25
  • 5
    `.angular-cli.json` is created by `@angular/cli` automatically when you create new project from `ng new` – Touqeer Shafi Jul 20 '17 at 07:27
  • 1
    I have created project not using cli, and after I installed cli using npm – POV Jul 20 '17 at 08:44
  • 2
    See this post: [Converting an existing angular 2 project to use angular CLI](https://stackoverflow.com/questions/38836487/converting-an-existing-angular-2-project-to-use-angular-cli) – Andrei Matracaru Aug 07 '17 at 11:02
  • Well, the quick fix would be to create a new app using angular cli and copy the `.angular-cli.json` to your project root! – snippetkid Oct 25 '17 at 14:30

9 Answers9

101

In Angular 6, .angular-cli.json has been replaced with angular.json

For Angular < 6:

Create a new file with name '.angular-cli.json' and add this file in your main directory.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "my-app"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}
Raj
  • 22,346
  • 14
  • 99
  • 142
Manik Biradar
  • 1,294
  • 2
  • 9
  • 7
  • 73
    In Angular 6, `.angular-cli.json` has been replaced with `angular.json`! Hope this helps others who came here wondering where their config file went! – adam0101 May 24 '18 at 15:54
  • 2
    @adam0101 are the contents / nodes within the file changed too. I found the angular.json file but there is no node that says "apps"? A lot of the other nodes are changed too! – Yash Saraiya Jul 25 '18 at 09:00
  • When you say main directory, are you referring to the root folder? Example, {angular_project_folder}\.angular-cli.json ? Like that? 2nd question, is dot(.) necessary in the file name? – Marvin Glenn Lacuna Nov 06 '18 at 10:01
  • @adam0101 may I know where Can I find app in Angular.json file? – Pardeep Jain Aug 07 '19 at 06:19
31

Since Angular version 6 .angular-cli.json is deprecated. That file was replaced by angular.json file which supports workspaces.

iqqmuT
  • 653
  • 6
  • 8
12

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?

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.

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.

Chaos7703
  • 691
  • 9
  • 18
9

You are just outside the directory which you are working. Enter into the directory which your project is there and run command ng g c name.

Liam
  • 27,717
  • 28
  • 128
  • 190
Shiva shankar
  • 91
  • 1
  • 1
1

I found similar error it was located to C:\Users\sony\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@schematics\angular\workspace\files

it is installed in windows try to search in c drive angular.json you will view the file

Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
  • Can you explain that further? What should one do after viewing that specific file? How does that solve the problem? – Nico Haase Dec 28 '18 at 07:16
1

In angular.json you can insert all css and js file in your template. Other ways, you can use from Style.css in src folder for load stylesheets.

@import "../src/fonts/font-awesome/css/font-awesome.min.css";
@import "../src/css/bootstrap.min.css";
@import "../src/css/now-ui-kit.css";
@import "../src/css/plugins/owl.carousel.css";
@import "../src/css/plugins/owl.theme.default.min.css";
@import "../src/css/main.css";
imTachu
  • 3,759
  • 4
  • 29
  • 56
Mojtaba Nava
  • 858
  • 7
  • 17
0

I couldn't see .angular-cli.json too. Because my Angular version is 6. ng version -> Angular CLI : 6.0.7. Check your Angular version.

0

As far as I know Angular-cli file can't be created via a command like Package-lock file, If you want to create it, you have to do it manually.

  1. You can type ng new to create a new angular project

  2. Locate its .angular-cli.json file

  3. Copy all its content

  4. Create a folder in your original project, and name it .angular-cli.json

  5. Paste what copied from new project in newly created angular cli file of original project.

  6. Locate this line in angular cli file you created, and change the name field to original project's name. You can find the project name in package.json file

project": {
  "name": "<name of the project>"
},

However, in newer angular version now it uses angular.json instead of angular-cli.json.

Don Dilanga
  • 2,722
  • 1
  • 18
  • 20
-1

If you copy paste your project the .angular-cli.json you wil not find this file try to create a new file with the same name and add the code and it wil work.

Errabbah Tarik
  • 214
  • 1
  • 2
  • 11