问题
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 ajv-keywords@3.1.0 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.
回答1:
You need to delete ng folder from /usr/local/bin
Install again
sudo rm -rf /usr/local/bin/ng
sudo npm i -g angular/cli
回答2:
I was having the same issue as you but I found that if I went to the /usr/local/bin folder and erased the ng file then reinstalled angular it worked.
If you already tried to install angular follow this the uninstall directions here https://github.com/angular/angular-cli/wiki/stories-1.0-update, then erase the ng file then reinstall.
来源:https://stackoverflow.com/questions/48808384/angular-cli-error-path-and-code-eexist