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?
Since Angular version 6
.angular-cli.json
is deprecated. That file was replaced byangular.json
file which supports workspaces.In Angular 6,
.angular-cli.json
has been replaced withangular.json
For Angular < 6:
Create a new file with name '.angular-cli.json' and add this file in your main directory.
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.
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.
You can type ng new to create a new angular project
Locate its .angular-cli.json file
Copy all its content
Create a folder in your original project, and name it .angular-cli.json
Paste what copied from new project in newly created angular cli file of original project.
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
However, in newer angular version now it uses angular.json instead of angular-cli.json.
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
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
.