How can I install web3 globally in Ubuntu 16.04? - npm

I am trying to install web3 via npm.
sudo npm install -g web3
But I faced below error.
tom#ubuntu:/$ sudo npm install -g web3
npm WARN deprecated fs-promise#2.0.3: Use mz or fs-extra^3.0 with Promise
Support
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 ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b browserifyCompatible
git://github.com/frozeman/WebSocket-Node.git
/home/tom/.npm/_cacache/tmp/git-
clone-d38db07b
npm ERR! /home/tom/.npm/_cacache/tmp/git-clone-d38db07b/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/tom/.npm/_logs/2018-02-07T14_42_37_459Z-debug.log
How can I install web3?

Looks like your local .npm permissions are messed up. Just remove NPM cache by running:
sudo rm -rf /home/tom/.npm
and then try again.

Related

NPM completely broken and won't reinstall after failed upgrade

Mac Catalina 10.15.6
I already had npm installed. I wanted to upgrade so I ran the following.
npm install -g npm
Below is the output:
$name#$names-MacBook-Pro desktop % npm install -g npm
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm ERR! code EEXIST npm ERR! syscall symlink npm ERR! path
../../../lib/node_modules/npm/man/man1/npm-bin.1 npm ERR! dest
/usr/local/share/man/man1/npm-bin.1 npm ERR! errno -17 npm ERR!
EEXIST: file already exists, symlink
'../../../lib/node_modules/npm/man/man1/npm-bin.1' ->
'/usr/local/share/man/man1/npm-bin.1' npm ERR! File exists:
/usr/local/share/man/man1/npm-bin.1 npm ERR! Remove the existing file
and try again, or run npm npm ERR! with --force to overwrite files
recklessly.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/$name/.npm/_logs/2020-10-04T14_41_02_611Z-debug.log
Now all NPM commands fail.
zsh: command not found: npm
Everything from:
npm -v
sudo npm install npm -g
I just used home brew to upgrade NPM and it deleted and reinstalled all the necessary files.
This generally works for me on Mac:
brew upgrade
brew cleanup
brew install npm
(note you'll need the xcode tools if you don't have it - try xcode-select --install or check out this answer.)
Now, try npm install again and see if that changes anything.
Also, see this potentially related answer.

Vue CLI error creating new project (npm error)

Please help me on this. I can't create a new Vue CLI project. It previously works good! Now not working...
Vue CLI v4.2.3
✨ Creating project in /Web develop/Vue Projects/new.
🗃 Initializing git repository...
⚙️ Installing CLI plugins. This might take a while...
npm ERR! Unexpected end of JSON input while parsing near '...loader":"~0.8.0","js-'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Malaka/.npm/_logs/2020-03-25T06_30_10_474Z-debug.log
ERROR command failed: npm install --loglevel error
seems a cache error
run
npm cache clean --force
then try create the project again
That's weird. I'd just try re-installing the Vue cli package.
There is a deprecated vue-cli package, it could be you have that installed rather than the official one #vue/cli.
Either way just uninstall it with
npm uninstall [your-vue-cli-package] -g
Then re-install it again.
npm install #vue/cli -g
lets try this
$ sudo npm uninstall -g vue
$ sudo npm uninstall -g vue-cli
$ sudo npm uninstall -g #vue/cli
$ sudo npm cache clean --force
$ sudo npm install -g vue
$ sudo npm install -g #vue/cli
problem log:
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\DraKoan\AppData\Local\npm-cache\_logs\2022-04-19T17_09_34_388Z-debug-0.log
ERROR Error: command failed: npm install --loglevel error --legacy-peer-deps
Error: command failed: npm install --loglevel error --legacy-peer-deps
at ChildProcess.<anonymous> (C:\Users\DraKoan\AppData\Roaming\npm\node_modules\#vue\cli\lib\util\executeCommand.js:138:16)
at ChildProcess.emit (node:events:526:28)
at ChildProcess.cp.emit (C:\Users\DraKoan\AppData\Roaming\npm\node_modules\#vue\cli\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
Solve:
check proxy at config
npm config edit
npm config --global edit
clean and set proxy
npm config set proxy null
npm config set proxy false

npm install etherlime fails

I am trying to install etherlime on Ubuntu 16.04 and npm 6.5.0:
sudo npm install etherlime
Even if I run the above command with sudo it gives me this error:
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/LimeChain/solidity-coverage.git /home/username/.npm/_cacache/tmp/git-clone-823333ab
npm ERR! /home/username/.npm/_cacache/tmp/git-clone-823333ab/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/username/.npm/_logs/2019-01-07T08_00_45_775Z-debug.log
Try this one
npm i -g etherlime
or refer this link https://www.npmjs.com/package/etherlime
I've never used etherlime but you do not need to use sudo when using the npm command. Maybe npm is installed in a wrong way or You have an error due to the permissions of your directory.
Try with this:
sudo chown -R username directory.
I need the error logs to understand what the problem is, but remember to use npm in a sub-directory and not in the user's home directory.
mkdir folderName
cd folderName
npm install etherlime
You can found this answer useful.
Obviously before to try this You have to install etherlime globally (npm install -g etherlime)

I Can't install Web3

I have to install Web3 which is a ethereum library but I can't install in linux mint 18.
$ sudo npm install web3 --save
[sudo] password for taylor:
npm WARN deprecated fs-promise#2.0.3: Use mz or fs-extra^3.0 with Promise Support
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 minimatch#0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! code ENOGIT
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/taylor/.npm/_logs/2018-02-01T12_55_24_014Z-debug.log
What can I do?
The error clearly states that you are missing git.
Try installing git first and give it a go ?

Why does Fabric Composer npm-install fail for my Ubuntu setup?

I'm a newbie to npm and hyperledger fabric-composer
Question: What is the problem with my setup? What is the strategy to investigate and solve such errors?
What I did:
Setup Ubuntu Linux 14.04 LTS (64-bit)
Installing prerequisites using the script provided on
https://fabric-composer.github.io/tasks/prerequisites.html
Executing npm install causes (don't know if this info is sufficient):
[...]
File "/usr/local/lib/python2.7/dist-packages/docker/transport/ssladapter.py", line 22, in <module>
urllib3.connection.match_hostname = match_hostname
AttributeError: 'module' object has no attribute 'connection'
npm ERR! Linux 4.4.0-31-generic
npm ERR! argv "/home/mjh/.nvm/versions/node/v4.6.2/bin/node" "/home/mjh/.nvm/versions/node/v4.6.2/bin/npm" "install"
npm ERR! node v4.6.2
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! getting-started#1.0.0 install: `scripts/download-hyperledger.sh && scripts/start-hyperledger.sh && npm run deployNetwork`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the getting-started#1.0.0 install script 'scripts/download-hyperledger.sh && scripts/start-hyperledger.sh && npm run deployNetwork'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the getting-started package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! scripts/download-hyperledger.sh && scripts/start-hyperledger.sh && npm run deployNetwork
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs getting-started
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls getting-started
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/mjh/sample-applications/packages/getting-started/npm-debug.log
See link for detailed npm-debug.log file
https://gist.github.com/mjh-halder/9fe473b44f0a731c996bbc5754011013
I've seen this problem before on trusty (14.04) and relates to an out of date urllib3 library for python, which is used by docker compose.
depending on which version of pip you have installed you can update the urllib library as follows
pip install --upgrade pip
pip install -U urllib3
You are missing permissions, so you need to do sudo npm-install ...
The issue here is related to the last part of the installation script - this is the part that installs the docker-compose tool. Testing this today on a clean Ubuntu 14.04 LTS image, that was the cause.
I'd recommend installing docker-compose following the instructions on the docker site. (https://docs.docker.com/compose/install/)
In effect this is
curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o
chmod +x /usr/local/bin/docker-compose
Run the docker-compose --version to check it's installed correctly
$ docker-compose --version
docker-compose version: 1.10.0
Then run the rest of the Fabric Composer scripts as before.
We're updating the script - but this should get you going.