0

I have to be able to run a legacy application written with Angular 4. But when I execute ng serve, I get the error The serve command requires to be run in an Angular project, but a project definition could not be found.

My Angular CLI version is 8.2.2 and I have Node 10.16. I guess I cannot run an old Angular application with this version of Angular CLI, can I ?

yet the project package.json is referencing "@angular/compiler-cli": "4.1.3", and I've installed all the packages with npm i.

I noticed the project is missing an angular.json file but as far as I remember, Angular 4 did not use this kind of file.

any idea ?

Sam
  • 13,934
  • 26
  • 108
  • 194
  • have you seen this -> https://stackoverflow.com/questions/43018777/angular-cli-different-versions-in-the-same-computer – Arikael Nov 05 '19 at 11:02

1 Answers1

2

When you use ng serve directly on the command line, it will use your globally installed Angular version which is 8.2.2. To use the local version you could either use the npx command:

npx ng serve

This will use the angular cli found in the local project.

Or you could use an npm script in your package.json.

"scripts": {
    "ng": "ng",
    "start": "ng serve",
}

then you can use npm run start.

C.OG
  • 6,236
  • 3
  • 20
  • 38