J.Doe
J.Doe

Reputation: 596

Re-Install Angular Correctly

I had problems with my dependencies in Angular so i reinstalled it in my project. So, what I did was this:

npm uninstall -g angular-cli
npm cache clean or npm cache verify
npm install -g @angular/cli@latest

rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

However now, when trying to use npm start or ng serve, this happens

The serve command requires to be run in an Angular project, but a project definition could not be found.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ng serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.

additional to that, when trying the npm install command I get strange warnings:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 7337 packages in 4.116s
found 20 vulnerabilities (3 low, 14 moderate, 3 high)

It worked before uninstalling (except for the dependencies) so i'm getting really frustrated.

First thing I found googling this problem of course was

Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found

but after doing this, the problem still consisted.

How can I reinstall Angular correctly?

Upvotes: 2

Views: 9329

Answers (2)

plm
plm

Reputation: 198

Note that there has been an update to checking the version.

OLD: ng --version

NOW: ng version

As of 2-AUG-2022

Upvotes: 0

Dixit Savaliya
Dixit Savaliya

Reputation: 413

Try this,

    npm uninstall -g angular-cli
    npm uninstall -g @angular/cli
    npm cache clean
    npm install -g @angular/cli@latest

Then when it gets done successfully you may try:

ng --version

Upvotes: 8

Related Questions