Ami Vyas
Ami Vyas

Reputation: 129

Getting error while building angular code

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

Upvotes: 1

Views: 790

Answers (1)

RTYX
RTYX

Reputation: 1334

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

Upvotes: 3

Related Questions