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 ?

1

1 Answer 1

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.

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.