简体   繁体   中英

Installing web3 package, npm gave me an error that “Permission denied”

I even used the sudo command, I got an error about permission.

$ sudo npm install web3
npm WARN deprecated tar.gz@1.0.7: ⚠️  WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b browserifyCompatible git://github.com/frozeman/WebSocket-Node.git /home/taylor/.npm/_cacache/tmp/git-clone-f2da992b
npm ERR! /home/taylor/.npm/_cacache/tmp/git-clone-f2da992b/.git: Permission denied
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/taylor/.npm/_logs/2018-02-04T08_56_17_771Z-debug.log

Looks like your local .npm permissions are messed up. Just remove NPM cache by running:

sudo rm -rf /home/taylor/.npm

and then try again. I would also recommend not to use sudo when running npm install , unless you want to install a global package (you usually don't).

if you use sudo to install packages, you will get "EACCES: permission denied" error next time when you install packages, because those packages installed via sudo will have root as their owner, instead of you being the owner.

install web3.js via yarn:

$ yarn add web3 --dev

I had this same problem with the windows machine. I did the following.

  • Delete npm and npm-cache from the %AppData%
  • Reinstall the node by selecting the repair option
  • Restart the machine
  • Install web3 using the command npm install -g web3

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