Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-Install Angular Correctly

Tags:

angular

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?

like image 642
J.Doe Avatar asked Jul 12 '26 19:07

J.Doe


1 Answers

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

like image 129
Dixit Savaliya Avatar answered Jul 15 '26 10:07

Dixit Savaliya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!