1

I have created angular app but getting error while executing command "ng serve"

Error is : The build command requires to run in an angular project, but a project definition could not be found.

I have tried to install @angular/cli, devkit core and angular packages but still I am facing the same error.

I don't know what I am missing. I have searched a lot in google but unable to resolve this error.

Edited: Image added. enter image description here

12
  • 2
    Ensure that you are running ng serve in the project directory Commented Jan 8, 2019 at 14:08
  • I am writing correct command in cli and I have edited my question. Commented Jan 8, 2019 at 14:09
  • 1
    could you please post a snap of your command prompt? Commented Jan 8, 2019 at 14:14
  • 1
    @AmiVyas after creating new project by 'ng new myapp' you need to go in 'myapp' directory by 'cd myapp' then run 'ng serve' Commented Jan 8, 2019 at 14:15
  • 1
    share screen shot of your command prompt, try to create a new empty project and serve that Commented Jan 8, 2019 at 14:18

1 Answer 1

3

In the terminal (commands may vary depending on your terminal):

[my-folder] ng new my-test
    ...
    ...
    ...
[my-folder] ls
[my-folder] . .. my-test
[my-folder] cd my-test
[my-test] ng serve

If at this point you get that error, then find your current Angular CLI version and update it:

[my-test] ng -v
[my-test] 
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.7.4
Node: 8.9.3
OS: darwin x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

[my-test] ng update @angular/cli --migrate-only --from=<1.7.4>

With that, you'll update your Angular CLI. Pay attention to your own version. As you can see, in my case it was 1.7.4, but your's will probably be different.

Based on https://github.com/angular/angular-cli/issues/12215#issuecomment-433593036

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

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.