Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CLI Error path and code EEXIST

I first installed npm and made sure it was up to date. Then I tried installing angular but I was faced with errors

~ kode$ sudo npm install -g @angular/cli

Password:

npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! path /usr/local/bin/ng

npm ERR! code EEXIST

npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/local/bin

npm ERR! File exists: /usr/local/bin/ng

npm ERR! Move it away, and try again.


npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/kode/.npm/_logs/2018-02-15T13_10_57_836Z-debug.log

I don't understand how it tells me that the file already exists yet when I run any ng command it tells me:

ng: command not found

I'm fairly new to node and angular all together so here's what I tried:

I tried uninstalling angular: sudo npm uninstall -g @angular/cli

Then reinstalling it: sudo npm install -g @angular/cli

And it didn't work of course.

If you do know how to solve this please help a beginner out, thank you.

like image 228
Kode Ch Avatar asked Feb 15 '18 13:02

Kode Ch


1 Answers

You need to delete ng folder from /usr/local/bin:

 sudo rm -rf /usr/local/bin/ng 

Then retry the installation:

 sudo npm i -g @angular/cli 
like image 85
Anil Kumar Avatar answered Oct 11 '22 10:10

Anil Kumar