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).
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
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
Related
I get this error when I try to install node
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\lenovo\AppData\Roaming\npm-cache\_logs\2020-08-29T13_30_35_085Z-debug.log
try this first before installing node.
sudo npm cache verify
sudo npm cache clean --force
After installing verify your installation:
node --version
several things you can try are following
sudo npm cache clean --force
trying changing ownership of npm and try npm latest
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin
npm install -g npm#latest
give it a try by clearing up the proxy, maybe you're behind proxy
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
Lately i would like to recommend you to use the NVM package. it is not the solution to your answer directly but its a great way to manage and have different node/npm environments
https://davidwalsh.name/nvm
I've been getting the following warnings lately whenever I run any npm script:
npm WARN npm npm does not support Node.js v12.4.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/
It says that I should upgrade to a newer version, but v12.4 is the newest version. Even though the scripts run fine, I think there's no guarantee and something might break at any moment.
I've also tried updating npm in case there's a newer version using npm install npm -g but got the error:
npm ERR! path /usr/local/Cellar/node/12.4.0/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'] {
npm ERR! stack: 'Error: EACCES: permission denied, access ' +
npm ERR! "'/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
Then I've seen that Homebrew version of npm can't be updated using npm itself, so I tried updating through Homebrew using brew upgrade npm but got this error:
Error: npm 12.4.0 already installed
For some reason Brew mixes up nodes and npms versions.
What am I doing wrong and how can I get rid of this warning?
What worked for me:
if you try running this command "npm cache clean -f" and it doesn't work,
on your windows machine(mine is windows 10)
access the "npm" and "npm-cache" folders in this location "~\AppData\Roaming\"
delete these two folders "npm" and "npm-cache".
go to your windows search bar and search for Node, right click to open file location, run the uninstaller to uninstall NodeJs.
then visit nodejs.org and download and install node again, if you've already downloaded it, visit the folder where you downloaded it to reinstall it.
after installation, check your version of npm by typing "npm -v" on your command terminal to see the new updated version of npm installed on your machine.
now you're all set, Happy coding.
Seems like you messed up with permissions in /usr/local.
Here is how to fix that:
Fix /usr/local permissions:
sudo chown -R `id -un`:`id -gn` /usr/local
Clean npm cache and uninstall it:
npm cache clean -f
npm -g uninstall npm
Reinstall node (with npm)
brew reinstall node
Upgrade npm:
npm -g i npm
That should bring npm#6.9.2.
You should avoid using sudo while installing software with brew or npm, that could cause issues like this.
If you have nvm you may have an issue in which your node version installed at a certain version didn't match.
For example, I accidentally used: npm i -g node --force resulting in my nvm v12.21.0 to point to v16.5.0 (the latest version of node at that time directly downloadable).
To solve: I ran:
Just for good measure brew uninstall nvm
brew install nvm.
nvm uninstall 12.21
nvm install 12.21
Just for good measure I ran npm i -g npm resulting in the latest version of npm installed on that virtual node.
After installing within some repo (using npm i) you may also want to check your: ~/.npmrc.
email=myemail#company.com
registry=https://artifactory.company.com/npm/npm/
always-auth=true
user-agent=npm/6.14.11 node/v12.21.0 darwin x64
_authToken=siofjwoirgiowrgnioaenrvoianeoiio32noi23nio23nio23nio
It should look something like this: (or you might not have any of that.
Had the same issue with Debian 10 (buster) when I tried installing the npm and node.js. They were incompatible and wouldn't update. This was what I found works for me.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
The nodejs package was installed at a different path and I manually deleted the old package (in /usr/bin/) and added a symlink to point to the new one (in /usr/local/bin).
sudo rm /usr/bin/node
sudo ln -s /usr/local/node /usr/bin/node
This is the initial printouts from running the commands. The npm version updates from 5.8.0 to 8.1.2. But the nodejs version stayed at 10.24.0 even after reboot with hash -r.
None of the answers here worked. I had to delete the npm and npm-cache folders, then reinstall npm. Details here: npm does not support Node.js v12.18.3
After step 4 posted by Styx, and if node claims installation fo a newer version but npm -v keeps showing outdated version
Code for Mac and node installed with brew:
cd /usr/local/bin/
mv npm npm-backup
mv npx npx-backup
ln -s /usr/local/Cellar/node/14.2.0/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
ln -s /usr/local/Cellar/node/14.2.0/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
npm -version
6.14.5
I hit this issue and the steps above didn't work for me. I think it can happen if you try to upgrade Node or NPM without updating the other also. At least I think that's what happened to me.
I was trying to create a new Angular project and I had a very old version on my machine. I got an error to upgrade Node, so I bumped it to the latest version. After that I got the error running any npm command.
I resolved it simply by going to:
https://nodejs.org/en/download/
Getting the latest version and installing that in a pkg file (mac). After install was complete I was able to run everything. I'm guessing it worked because the versions of each mismatched, so one wouldn't run without the other being downgraded.
I also tried the brew option but I was getting other issues. My corporate machine sometimes blocks installations in that route, so it might work for others.
For Windows, this was driving me crazy, and all of the above solutions were not working, I would still get the old version of node showing for node -v.
For me simply killing the terminal window and starting it again resolved the issue. No amount of cache clearing worked until this. I know it sounds dumb, but that's what resolved this for me in the end. Hope this helps someone else not lose hours farting around with this.
I've have this issue in npm -v package,so you have to easy step in follow of solve this problem.
npm use stable
nvm use stable
nvm cache clear
nvm install stable --default
you can closed the terminal then check the `npm --version
Looks like a permission issue. Try with sudo
To install a Bootstrap theme I want to run npm install. However I always receive a permission denied error.
I already tried nvm and then switched with nvm use 10.9.0 to run npm install.
I also tried sudo chown -R $(whoami) ~/.npmand sudo chown -R $USER /usr/local/lib/node_modules. Neither solved it and now I am bit out of ideas how I can continue. I use macOS High Sierra.
Marcs-MBP-3:masterclass Marc$ npm install
npm WARN deprecated gulp-uglifyjs#0.6.2: Since gulp-sourcemaps now works, use gulp-uglify instead
npm WARN deprecated babel-preset-es2015#6.24.1: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated browserslist#1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN checkPermissions Missing write access to /Users/Marc/Desktop/Dev/masterclass/node_modules
npm ERR! path /Users/Marc/Desktop/Dev/masterclass/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/Marc/Desktop/Dev/masterclass/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/Users/Marc/Desktop/Dev/masterclass/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/Users/Marc/Desktop/Dev/masterclass/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/Users/Marc/Desktop/Dev/masterclass/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Marc/.npm/_logs/2018-08-22T12_46_51_786Z-debug.log
For Mac;
Run this on the Terminal >
sudo chown -R $USER /usr/local/lib/node_modules
Check permissions of your project root with ls -l /Users/Marc/Desktop/Dev/masterclass/. If the owner is not $USER, delete your node_modules directory, try changing the owner of that directory instead and run npm install again.
cd /Users/Marc/Desktop/Dev
rm -rf ./masterclass/node_mdoules/
chown -R $USER ./masterclass/
cd masterclass
npm install
I tried everything in this thread with no luck on Big Sur, but then I tried this:
sudo npm install -g yarn
And it worked!
KIndly run the below commands:
To check the location of the package:
npm config get prefix
Then run this :
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Enter the password and run installation commands
It worked for me.
For me it was,
npm cache clean --force
rm -rf node_modules
npm install
I tried deleting manually but didn't help
I did this for nodemon and it work
sudo chown -R $USER /usr/local/lib/node_modules
then install the packages that you need
I was having a similar issue, but the accepted answer did not work for me, so I will post my solution in case anyone else comes along needing it.
I was running npm install in a project cloned from GitHub and during the clone, for whatever reason the write permission was not actually set on the project directory. To check if this is your problem, pull up Terminal and enter the following:
cd path/to/project/parent/directory
ls -l
If the directory has user write access, the output will include a w in the first group of permissions:
drwxr-xr-x 15 user staff 480 Sep 10 12:21 project-name
This assumes that you're trying to access a project in the home directory structure of the current user. To make sure that the current user owns the project directory, follow the instructions in the accepted answer.
I entered the following:
cd /Users/Marc/Desktop/Dev
rm -rf ./masterclass/node_mdoules/
chown -R $USER ./masterclass/
cd masterclass
npm install
once this was completed the results indicated warnings and one notice instead of previous result of no permission and error.
I then entered the following:
% sudo npm install --global firebase-tools
my result was success upon completion of the last terminal entry.
I have same problem because i install it from pkg, and i solve this problem use below step:
1. sudo rm -rf /usr/local/lib/node_modules/npm/
2. brew doctor
3. brew cleanup --prune-prefix ( or sudo rm -f /usr/local/include/node)
4. brew install node
i use this command :
sudo npm install -g #angular/cli
Gave password and worked for mw. Took 10 secs to install angular
NPM_CONFIG_PREFIX=~/.npm-global
Copy this line into ur terminal, then hit enter. Then install the necessary packages you need WITHOUT the term "sudo" in front of npm.
i.e.,
npm install -g jshint
the only thing that work on me sudo npm i -g clasp --unsafe-perm
Just do :
sudo npm install -g #sanity/cli && sanity init
it will ask sudo password and you are good to go
That is because you dont have the "node modules". You can install with this code:
npm install -g node-modules
then, create your react app with npm init react-app my-app
For Macs running Big Sur or Monterey:
sudo chown -R $USER /usr/local/bin
Run on macOS Terminal:
sudo chown -R $USER /usr/local/bin
It will ask for the password then you're good to go!
Hope this helps.
Ok my problem was that I thought I was installing on the path:
/Users/mauro/Documents/dev/react
Where my project was setup, but instead I was doing it on:
Users/mauro/Documents/dev/
One path higher and that is why it did not perform the installation in my case.
I simply did: cd react and voila I was able to install without problem
I'm unable to install puppeteer as a project dependency, and I've tried re-installing node. Anyone have an idea on how to fix this? Running Ubuntu 17.10 x64
sudo apt-get purge nodejs;
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -;
apt-get install -y nodejs;
sudo npm install -g n;
sudo n stable;
Node versions:
$ node -v
v9.4.0
$ npm -v
5.6.0
I try to install:
root#server:/var/www/html# npm install --save puppeteer
Error message:
> puppeteer#1.1.0 install /var/www/html/node_modules/puppeteer
> node install.js
ERROR: Failed to download Chromium r536395! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/var/www/html/node_modules/puppeteer/.local-chromium'
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/var/www/html/node_modules/puppeteer/.local-chromium' }
npm WARN project#1.0.0 No description
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer#1.1.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer#1.1.0 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! /root/.npm/_logs/2018-02-19T15_55_52_669Z-debug.log
I don't see any ways to fix this in the referenced issue: https://github.com/GoogleChrome/puppeteer/issues/375
EDIT 20th April 2019:
The easy solution suggested by lauraalvarezz1 is,
sudo npm install -g puppeteer --unsafe-perm=true
This is okay as long as you trust puppeteer and want it to install puppeteer globally.
However beware of using --unsafe-perm=true for permission related problems. Reasons are:
Running unsafe-perm=true with sudo, as a non-root user, will give the script root access. This might be okay only if you trust the script and do not concern about security that much.
You might need to use --no-sandbox in every script you run, because the chrome installed with this command might not run without this parameter. See this github issue.
You have installed npm with sudo. Thus anything you install globally will require sudo.
To install anything on var/www/html folder, either you have to own that folder,
sudo chown -R $USER /var/www/html
Or you can use nvm to manage npm. Technically it will use your home directory and your current user.
After installing nvm, you can install puppeteer globally with it,
npm i -g puppeteer
or you have to use sudo
sudo npm install --save puppeteer
However chromium will not be downloaded due to permission error, that's why you have to use ---unsafe-perm=true as stated before.
Security Related Resources:
Resolve this without sudo, you can use this answer.
Learn more about best practices dealing with /var/www folder, refer to this answer.
Best of luck!
Run this on your terminal:
sudo npm install -g puppeteer --unsafe-perm=true
Before you begin, make sure you have the most recent version of Node.js.
The Puppeteer Documentation states:
Note: Puppeteer requires at least Node v6.4.0, but the examples below use async/await which is only supported in Node v7.6.0 or greater.
You can check which version of Node.js you have using the following command:
node -v
# OR nodejs -v
If your version of Node.js is less then v7.6.0, you can completely uninstall your current version of Node.js.
Then, you can use complete the reinstallation using a PPA:
sudo apt update
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
sudo apt install build-essential
You can check the new versions of Node.js and NPM installed on your system:
node -v
npm -v
Finally, you can install Puppeteer:
sudo npm install puppeteer --unsafe-perm=true --allow-root
Now you can run Puppeteer scripts using the node command:
node puppeteer-script.js
I did:
yarn install --ignore-scripts
yarn install.
And it worked without sudo or global package installation.
It should work with npm too.
I have Ubuntu 20.04.
I attempted to do a sudo npm install -g appium on Mac OS 10.12.5.
I get this error:
info Chromedriver Install Installing Chromedriver version '2.30' for platform 'mac' and architecture '64'
info Chromedriver Install Opening temp file to write chromedriver_mac64 to...
Error: EACCES: permission denied, mkdir
'/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/2017820-44752-12jfqpb.z2hd'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appium-chromedriver#3.0.1 install: node install-npm.js
npm ERR! Exit status 1
npm ERR!
this is not a dup question, as this install attempt was with sudo, as the other one was not.
sudo npm install -g appium --unsafe-perm=true --allow-root
Worked for me
you are using npm so you have to use
sudo npm install --unsafe-perm
In unsafe mode with every command you run
hopefully, it will help
The -g option means install globally. When packages are installed globally, EACCES permission errors can occur.
Consider setting up npm to operate globally without elevated permissions. See Resolving Permission Errors for more information.
Option 1
The best way to avoid permission issues is to reinstall NodeJS and npm using a node version manager.
1. Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
You can close and reopen the terminal ou just open another terminal and check if nvm is installed properly with this command: command -v nvm.
2. To download and install the latest LTS release of NodeJS, run:
nvm install --lts
3. Set the newly installed NodeJS as the default environment:
nvm alias default lts/*
Option 2 (Does not apply for windows)
Change the owner of npm's directories to the current user:
sudo chown -R $(your_user) /usr/local/{lib/node_modules,bin,share}
sudo chown -R $(your_user) ~/.npm ~/.npmrc
I reinstalled Node/NPM. Problem solved.