0

I am trying to install web3 on my ubuntu 18.04 system. I am using the following command:

@lc2530hz:~$ sudo npm install -g web3

but I am getting the error:

sudo: npm: command not found

But when I am typing: @lc2530hz:~$ npm --version 6.14.6

Kindly guide me how to install web3.

Zulfi.

I am getting same response when I try without 'g' switch

@lc2530hz:~$ sudo npm install web3
[sudo] password for zulfi: 
sudo: npm: command not found


@lc2530hz:~$ npm --version
6.14.6
@lc2530hz:~$ 

Hi, I did "pip install web3"

I got following message at the end:

Successfully built bitarray pyrsistent cytoolz Installing collected packages: hexbytes, certifi, idna, urllib3, chardet, requests, pycryptodome, eth-hash, toolz, cytoolz, eth-typing, eth-utils, six, parsimonious, eth-abi, bitarray, eth-keys, eth-keyfile, rlp, eth-rlp, eth-account, websockets, base58, zipp, importlib-resources, netaddr, varint, multiaddr, ipfshttpclient, lru-dict, pyrsistent, typing-extensions, importlib-metadata, attrs, setuptools, jsonschema, protobuf, web3 Successfully installed attrs-20.3.0 base58-2.0.1 bitarray-1.2.2 certifi-2020.12.5 chardet-4.0.0 cytoolz-0.11.0 eth-abi-2.1.1 eth-account-0.5.4 eth-hash-0.2.0 eth-keyfile-0.5.1 eth-keys-0.3.3 eth-rlp-0.2.1 eth-typing-2.2.2 eth-utils-1.9.5 hexbytes-0.2.1 idna-2.10 importlib-metadata-3.3.0 importlib-resources-3.3.0 ipfshttpclient-0.7.0a1 jsonschema-3.2.0 lru-dict-1.1.6 multiaddr-0.0.9 netaddr-0.8.0 parsimonious-0.8.1 protobuf-3.14.0 pycryptodome-3.9.9 pyrsistent-0.17.3 requests-2.25.1 rlp-2.0.1 setuptools-51.1.0.post20201221 six-1.15.0 toolz-0.11.1 typing-extensions-3.7.4.3 urllib3-1.26.2 varint-1.0.2 web3-5.13.1 websockets-8.1 zipp-3.4.0

But when I am doing:

@lc2530hz:~$ web3

Command 'web3' not found, did you mean:

command 'deb3' from deb quilt

Try: sudo apt install

== Hi, When I did:

$ npm install -g web3

I got following output:

npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated multicodec@0.5.7: stable api reached

> bufferutil@4.0.2 install /home/zulfi/.nvm/versions/node/v10.22.0/lib/node_modules/web3/node_modules/bufferutil
> node-gyp-build


> keccak@3.0.1 install /home/zulfi/.nvm/versions/node/v10.22.0/lib/node_modules/web3/node_modules/keccak
> node-gyp-build || exit 0


> secp256k1@4.0.2 install /home/zulfi/.nvm/versions/node/v10.22.0/lib/node_modules/web3/node_modules/secp256k1
> node-gyp-build || exit 0


> utf-8-validate@5.0.3 install /home/zulfi/.nvm/versions/node/v10.22.0/lib/node_modules/web3/node_modules/utf-8-validate
> node-gyp-build

+ web3@1.3.1
added 352 packages from 328 contributors in 30.44s

But when I did:

zulfi@lc2530hz:~$ web3

Command 'web3' not found, did you mean:

command 'deb3' from deb quilt

Try: sudo apt install

==installing without 'g' $ npm install web3 npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated multicodec@0.5.7: stable api reached

bufferutil@4.0.2 install /home/zulfi/node_modules/bufferutil node-gyp-build

keccak@3.0.1 install /home/zulfi/node_modules/keccak node-gyp-build || exit 0

secp256k1@4.0.2 install /home/zulfi/node_modules/secp256k1 node-gyp-build || exit 0

utf-8-validate@5.0.3 install /home/zulfi/node_modules/utf-8-validate node-gyp-build

npm WARN saveError ENOENT: no such file or directory, open '/home/zulfi/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/home/zulfi/package.json' npm WARN zulfi No description npm WARN zulfi No repository field. npm WARN zulfi No README data npm WARN zulfi No license field.

  • web3@1.3.1 added 349 packages from 325 contributors and audited 354 packages in 18.391s

41 packages are looking for funding run npm fund for details

found 1 low severity vulnerability run npm audit fix to fix them, or npm audit for details zulfi@lc2530hz:~$ npm audit fix npm ERR! code EAUDITNOPJSON npm ERR! audit No package.json found: Cannot audit a project without a package.json

npm ERR! A complete log of this run can be found in: npm ERR! /home/zulfi/.npm/_logs/2020-12-21T23_36_40_266Z-debug.log

1

Try to install web3, without "-g", just npm install web3 (like the package states)

-g is used to have the command available in all directories, but you will only need web3 in your client javascript project.

EDIT 1: You can try adding the web3 script from a CDN like this: https://cdnjs.com/libraries/web3

EDIT 2:

To solve your npm problem in Ubuntu, try this (but is an OS issue, not web3):

sudo chown -R $(whoami) ~/.npm
4
  • My friend I am getting the same response. Still not able to install web3.
    – zak100
    Dec 21 '20 at 5:43
  • 1
    You can try to add the web3 script from a CDN like this: cdnjs.com/libraries/web3
    – AlexAcc
    Dec 21 '20 at 9:12
  • Hi, I used "pip install web3'. It sows several packages installed, see above. But when I am doing "$web3", it says command not found. Kindly guide me whether I installed web3 or not.
    – zak100
    Dec 21 '20 at 23:18
  • Hi, when I used "npm install web3", I got the following message: found 1 low severity vulnerability. I have added all the details above. Please guide me.
    – zak100
    Dec 21 '20 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.