2

I am going to create an app which deals with Angular5(front-end), Nodejs(middle-end) and MongoDB(back-end).

Below is the folder structure:

enter image description here

Package.json: "start": "ng build & node server.js"

Now when I am start the app by npm start, It throws the following error:

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

I hope node server is looking for this file to load angular codes. But it lies inside angular folder.

If I place both angular and node codes in same place, it works well.

But it looks more clumsy and a bit confusing. I don't want to compromise with my folder structure.

Can anyone please help to achieve the app working on the same folder structure that I would prefer?

Thanks in advance.

15
  • would you post your angular-cli.json content, please ? Commented Apr 5, 2018 at 4:59
  • can you check if you have another package .json or .angular-cli.json in the parent directories? There are cases where this can create problems with the project detection Commented Apr 5, 2018 at 5:03
  • @Arash pls find the angular.cli.json code: { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "name": "angular" }, "apps": [ { "root": "src", "outDir": "dist", "assets": [ "assets", "favicon.ico" ], Commented Apr 5, 2018 at 5:07
  • "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" ], Commented Apr 5, 2018 at 5:08
  • 2
    That's why it's not working because .angular-cli.json file is inside the angular folder and you trying to run from the parent folder. You need to put that file in mean folder and change all required path inside the angular-cli.json file Commented Apr 5, 2018 at 6:26

3 Answers 3

0

it might be that your global @angular/cli installation got corrupt. You may try a cache clean and reinstall..

npm cache clean
npm -g i @angular/cli
Sign up to request clarification or add additional context in comments.

1 Comment

I have done. but still no luck. getting the same error "Unable to find any apps in .angular-cli.json."
0

If you use angular cli for creating the project, then looks something wrong in the package.json, (as I seen your comment on the previous answer)

first uninstall angular cli if already install by using npm uninstall -g @angular/cli, then npm install -g @angular/cli after cli installation ng new [project name /folder name]

cd [project name /folder name]
ng serve --open

try once.

1 Comment

angular works fine. But my problem is how to combine it with node since both angular and node having node_modules folder and package.json file. see my folder structure in the post. i wish to know whether that structure is possible or good one?
0

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.

Reference URL: How to generate .angular-cli.json file in Angular Cli?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.