1

I have an Angular 4 project that I created a couple of months ago. When I go into the Angular project folder and type in ng serve, I get this error:

You have to be inside an angular-cli project in order to use the serve command.

Any idea what is wrong?

Is there some specific file that I can verify is there?

As a side note, I create a ng new Folder2 and was able to successfully run ng serve in that folder.

7
  • is your project built with angular cli ? if so, do you have file .angular-cli.json in a project folder? Otherwise you might be running the ng serve command from the wrong folder. Commented Oct 4, 2017 at 3:13
  • Please post how your folder tree looks like Commented Oct 4, 2017 at 3:14
  • go down another level dude, you at the parent folder Commented Oct 4, 2017 at 3:14
  • .angular-cli.json is there. Going down another level (outside of the project) didn't help. Commented Oct 4, 2017 at 3:17
  • did your .angular-cli.json has "apps": [ ] property declared and what is your cli version on a project? Commented Oct 4, 2017 at 3:18

1 Answer 1

4

For me it is seems like as you didn't touch the project for so long you might have an older version of the angular cli in you project than your global version or way around.

if you run ng -v outside your project it show you global cli version
if you run ng -v inside your project it will show you local cli version, also you can check the cli version in package.json in devDependencies

So you have two options.
1 update angular cli
2 run npm run ng serve this way npm will run the local angular cli, the one form package.json file

Sign up to request clarification or add additional context in comments.

4 Comments

Outside of the project folder: angular-cli: 1.0.0-beta.28.3, node: 8.0.0. Inside the project folder is the same but I also have this output: @angular/cli: 1.0.3, which is the same version coming from package.json.
angular-cli is an old package you need to get rid of this. then run` npm install @angular/cli -g` to install the latest version.
Running npm run serve throws this error: npm ERR! missing script: serve.
btw npm run ng serve that the right command to run local cli, sorry :)

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.