简体   繁体   中英

i have error install angular and npm package

I delete the old version of angular and trying to install a new one after update Nodejs and get this error this error appears when trying to install angular

安装

i trying to resolve by this steps and get different error

1) npm cache verify (If not running, add --force) 2) npm uninstall -g @angular/cli 3) check node --version and ng --version 4) npm i -g @angular/cli@latest 5) npm install --save-dev @angular/cli@latest 5) Delete node_modules and run npm install 6) Kill all instances of terminal

error :

admins-MacBook-Pro:~ admin$ sudo npm i -g @angular/cli@latest
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/admin/.npm/_logs/2019-08-01T03_26_03_978Z-debug.log
admins-MacBook-Pro:~ admin$ npm install
npm WARN saveError ENOENT: no such file or directory, open '/Users/admin/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/admin/package.json'
npm WARN admin No description
npm WARN admin No repository field.
npm WARN admin No README data
npm WARN admin No license field.

up to date in 1.274s
found 0 vulnerabilities

admins-MacBook-Pro:~ admin$ sudo npm install
npm WARN saveError ENOENT: no such file or directory, open '/Users/admin/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/admin/package.json'
npm WARN admin No description
npm WARN admin No repository field.
npm WARN admin No README data
npm WARN admin No license field.

up to date in 1.199s
found 0 vulnerabilities

Try:-

Add sudo if on Mac.

As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. If you're sure you want to delete the entire cache, rerun this command with --force.

Delete current project and create one new:- A) ng new PROJECTNAME then,

1) npm cache verify (If not running, add --force)
2) npm uninstall -g @angular/cli
3) check node --version  and ng --version
4) npm i -g @angular/cli@latest
5)  npm install --save-dev @angular/cli@latest
6) Delete node_modules and run npm install
7) Destroy all instances of terminal.

and,

Delete package.lock.json.

Create package.json by running  `npm init`, then follow step 6

如果您的项目已打开,请尝试关闭 vscode 或任何代码编辑器,然后再次尝试安装。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM