angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open wasifali opened this issue 9 years ago • 13 comments

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.

wasifali avatar Sep 05 '17 17:09 wasifali

works fine for me

cedvdb avatar Sep 06 '17 00:09 cedvdb

@cedvdb I've tried it at least 3 times still having the same issue.

wasifali avatar Sep 06 '17 05:09 wasifali

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.

filipesilva avatar Sep 06 '17 11:09 filipesilva

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.

wasifali avatar Sep 08 '17 22:09 wasifali

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.

ssurajita avatar Sep 17 '17 19:09 ssurajita

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

rberge avatar Sep 21 '17 21:09 rberge

i found the answer here, and it works now for me https://stackoverflow.com/a/45705204/3123228

mmamongy avatar Oct 27 '17 17:10 mmamongy

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.

filipesilva avatar Nov 04 '17 18:11 filipesilva

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.

jplew avatar Nov 11 '17 09:11 jplew

Hello everybody , I have the same error but what happens if I have a package.json instead of .angular-cli.json ?

saldivarl avatar Jan 16 '18 19:01 saldivarl

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

vivatum avatar Mar 22 '18 13:03 vivatum

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:

  1. Get one .angular-cli.json from any of your other project create with angular cli.(ng new command project always generates this file)

  2. 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.

  1. Rename the app.shared.module.ts to app.module.ts and change all the references of that (in app.browser.module.ts and in app.server.module.ts).

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

kingsuk avatar Mar 23 '18 09:03 kingsuk

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.