Web3.js: unable to install web3 on Ubuntu 16.04

Created on 20 Apr 2018  路  4Comments  路  Source: ChainSafe/web3.js

Hi

I am trying to install web3 on ubuntu virtual machine. I tried with both commands

sudo npm install --save web3 and
sudo npm install --save [email protected]

Here is the terminal output:

npm WARN deprecated [email protected]: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated [email protected]: 鈿狅笍  WARNING 鈿狅笍 tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar

> [email protected] preinstall /home/ltu/web3/node_modules/scrypt
> node node-scrypt-preinstall.js


> [email protected] install /home/ltu/web3/node_modules/scrypt
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ltu/web3/node_modules/scrypt/build'
gyp ERR! System Linux 4.13.0-38-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 /home/ltu/web3/node_modules/scrypt
gyp ERR! node -v v9.10.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/home/ltu/web3/package.json'
npm WARN web3 No description
npm WARN web3 No repository field.
npm WARN web3 No README data
npm WARN web3 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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/ltu/.npm/_logs/2018-04-20T10_50_03_804Z-debug.log

can you help me resolve this issue. I looked at many similar questions and tried to install build essentials. But this also didn't worked.

Most helpful comment

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

All 4 comments

I tried to update npm to latest version and restated the vm and installed the web3. It worked.

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

@rayeaster good jod. it worked

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

Was this page helpful?
0 / 5 - 0 ratings