无法在Ubuntu 18.04中安装Web3



我正在Ubuntu 18.04中安装Web3.js,并具有以下命令:

sudo npm install -g web3

并有以下错误:

> scrypt@6.0.3 preinstall /usr/local/lib/node_modules/web3/node_modules/scrypt
> node node-scrypt-preinstall.js
Error: Error: Command failed: ./configure
./configure: line 1904: config.log: Permission denied
./configure: line 1914: config.log: Permission denied

> scrypt@6.0.3 install /usr/local/lib/node_modules/web3/node_modules/scrypt
> node-gyp rebuild
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/web3/node_modules/scrypt/build'
gyp ERR! System Linux 4.15.0-45-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/web3/node_modules/scrypt
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/chakshu/.npm/_logs/2019-03-08T15_40_18_402Z-debug.log

尽管sudo npm install -g web3@0.20.7工作正常,但我想要更新的Web3.js。

@kashish khullar,您的解决方案在大多数软件包中都可以正常工作,但是当我尝试安装毛毛雨时不起作用。现在我找到了这一点的根本原因。我在Ubuntu 18.04中安装了带有二进制文件的nodejs,这显示了上述错误,其中许多NPM软件包(如Web3.js)都显示了上述错误。因此,我完全从系统中卸载了nodejs和npm,然后再次使用Apt-Get软件包管理器(即sudo apt install nodejs npm)安装它。现在一切正常,没有任何问题。

sudo npm install --save web3 --unsafe-perm=true --allow-root

最新更新