I've followed these steps
npm install -g @angular-cli
ng new project-name
then copy that project into a new directory and ran the command
ng g component cmp-name
and got the error
Unable to find any apps in
.angular-cli.json
.
I have followed #6503 , #5616 and #5661 but didn't get any luck cause it's not working.
works fine for me
@cedvdb I've tried it at least 3 times still having the same issue.
Heya, can you check if you have other package.json
or .angular-cli.json
in the parent directories? There are cases where this can create problems with the project detection. If that's the case, please let us know of the directory structure so we can try to reproduce.
Well yes @filipesilva it was happening due to the reason that parent directory had another .json
file, I have changed the structure and moved the app in a newly created directory and it is working.
I am also facing the same issue. I just created a sample angular app using _ng new hello-world_
Next I was trying to create a component inside the project path using _ng g c course_
I am getting the same error _Unable to find any apps in .angular-cli.json
_
Please help me to fix this issue if anyone have faced the same.
FirstFormpackage_json.txt
Me too. I cloned the angular Quickstart from git hub.
git clone https://github.com/angular/quickstart.git
I then changed the name of the directory and ran the ng generate class and got an error. I ran this command from within the project directory (e.g. it would have been "quickstart" but I renamed it)
ng generate class Heroes
Unable to find "@angular/cli" in devDependencies.
Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"聽
installing class
Unable to find any apps in .angular-cli.json
.
I tried again. I cloned a new Quickstart from git hub . (same command above)
cd quickstart
1178477-C1MRF34AG944:quickstart mymainuserdirectory$ ls
CHANGELOG.md karma.conf.js
LICENSE non-essential-files.osx.txt
README.md non-essential-files.txt
bs-config.e2e.json package.json
bs-config.json protractor.config.js
e2e src
karma-test-shim.js tslint.json
1178477-C1MRF34AG944:quickstart mymainuserdirectory$ ng generate class Hobbes
Unable to find "@angular/cli" in devDependencies.
Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"
node_modules appears empty, you may need to run npm install
Now to back up, I had installed angular cli globally a while ago using
npm install -g @angular/cli
Also here is my directory structure, The project files are all in one directory called
"Angst"
"Angst" has as its contents 4 project directories and no standalone files.
Angst directory contains Project 1 dir(Called FirstForm), Project 2 dir, Project 3 dir, Project 4 dir
The parent of "angular does not have a .json file. There is one at a high level and then down into a different directory
I tried the "ng generate class Hobbes" in the FirstForm directory. Just for reference, I did not create that directory with the git clone command, I used ng install. In that directory it worked
ng generate class Hobbes
installing class
create src/app/hobbes.ts
FirstFormpackage_json.txt
quickstartpackage_json.txt
In case it helps, here is how I created the FirstForm directory/project
1178477-C1MRF34AG944:Angst mymainuserdirectory$ node -v
v6.11.2
1178477-C1MRF34AG944:Angst mymainuserdirectory$ npm -v
3.10.10
1178477-C1MRF34AG944:Angst mymainuserdirectory$ cd Angst
-bash: cd: Angst: No such file or directory
1178477-C1MRF34AG944:Angst mymainuserdirectory$ ls
1178477-C1MRF34AG944:Angst mymainuserdirectory$ ng new FirstForm
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Successfully initialized git.
Project 'FirstForm' successfully created
I attached the package.json from each of these (I did that twice because I couldn't tell if it was there or not - sorry can't see how to delete the extra). I had to give them a txt suffix and renamed them with the project name. To summarize, in Quickstart, I can't use the generate component and in First Form I can.
quickstartpackage_json.txt
i found the answer here, and it works now for me
https://stackoverflow.com/a/45705204/3123228
Closing as the @wasifale says he got it sorted (https://github.com/angular/angular-cli/issues/7604#issuecomment-328230900). @rberge the quickstart that you cloned wasn't actually a CLI app, you should use ng new
to make CLI apps instead.
I had this exact error message, and learned that the problem was I was attempting to run my ng
commands from the wrong directory. All I had to do was cd
into the directory containing my .angular-cli.json
and it started working.
Hello everybody , I have the same error but what happens if I have a package.json instead of .angular-cli.json ?
I had a same issue. I can't find .angular-cli.json
by the Finder.
BUT! When I open my project by Visual Studio Code, I can find this file
I believe in most of the cases the problem is happening with DOTNET core angular template.
If you are using dotnet core angular template:
It doesnot provide .angular-cli.json out of the box because it is not created through ng cli.
What you can do is:
Get one .angular-cli.json from any of your other project create with angular cli.(ng new command project always generates this file)
Paste it in your root directory of application.
Find and change the root tag to ClientApp.
Example:
"apps": [
{
"root": "ClientApp",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
don't worry about output directory and other tags as you would not be building your application through ng cli, so rest can be left same.
then you should be good to go,
Remember you have to specify your module name each and every time, and if you want to create it in the components folder just like the default structure you need to specify it.
So your command should look like:
ng g component components/[ComponentName] --module app
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
i found the answer here, and it works now for me
https://stackoverflow.com/a/45705204/3123228