Getting error "EACCES: permission denied" when i install cypress - cypress

When i try to install cypress using this commnad:
sudo npm install cypress
or
sudo npm install -g cypress
It is giving me this error:
Error: EACCES: permission denied, open '/Users/humac/node_modules/cypress/cypress.zip'

Workaround: sudo npm install --unsafe-perm=true --allow-root cypress

In my case cypress had trouble accessing /root/.cache/Cypress upon npm install:
EACCES: permission denied, mkdir '/root/.cache/Cypress'
I found a relevant issue and ended up setting a custom cache dir:
export CYPRESS_CACHE_FOLDER=/app/.cache
npm install

Try using yarn package manager or downgrading npm to version 7.
For me it worked correctly.
I'm using Jenkins in an alpine linux container with node 16.
stage('Prepare-build') {
steps {
sh 'node --version'
sh 'npm --version'
sh 'ls -p'
sh 'git config --global --add safe.directory "*"'
sh 'yarn install'
}
}
The error I was getting is the following:
npm ERR! code 1
npm ERR! path /home/jenkins/agent/workspace/project/app/project-web-manager/node_modules/cypress
npm ERR! command failed
npm ERR! command sh /tmp/postinstall-716e113e.sh
npm ERR! Cypress cannot write to the cache directory due to file permissions
npm ERR!
npm ERR! See discussion and possible solutions at
npm ERR! https://github.com/cypress-io/cypress/issues/1281
npm ERR!
npm ERR! ----------
npm ERR!
npm ERR! Failed to access /root/.cache/Cypress:
npm ERR!
npm ERR! EACCES: permission denied, mkdir '/root/.cache/Cypress'
npm ERR!
npm ERR! ----------
npm ERR!
npm ERR! Platform: linux-x64 (Alpine Linux - 3.16.1)
npm ERR! Cypress Version: 10.6.0
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-08-18T17_09_27_887Z-debug-0.log
In my same case export the environment variable cypress cache folder did not work as expected, the error was even made mentioned above.
export CYPRESS_CACHE_FOLDER="/home/jenkins/agent/workspace/project/app/.cache"

After clearing my Cypress cache folder with cypress clear cache I ran into this issue as well.
This is what I did:
sudo rm -rf the Cypress folder in your .cache directory
For me I also deleted the Cypress folder in node_modules
Cleaned cache with npm cache clean --force
Installed Cypress with npm install cypress --save-dev
Hope this helps!

In my case I had issues running Cypress on Mac
An unexpected error occurred while verifying the Cypress executable.
----------
Error: EACCES: permission denied, open '/Users/me/Library/Caches/Cypress/9.7.0/binary_state.json'
----------
Platform: darwin-x64 (22.2.0)
Cypress Version: 9.7.0
The easiest think to do is to locate the folder within Finder app, and for both "Cypress" and "9.7.0" folder and adjust the permissions for "everyone" and "staff" to "Read & Write".
Note: You must click on the lock icon and use your mac admin/system password to change the permissions.

Related

checkPermissions and path Errors on installation

I am trying to install firebase and create-react-native-app on my terminal and keep getting the same errors on my terminal. Can someone please explain to me the root of my issue and a solution.
Please explain how i might be able to change my permissions
npm install -g create-react-native-app
npm install firebase-tools -g
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/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/matthewsixt/.npm/_logs/2018-12-21T18_46_00_558Z-debug.log
Can someone please explain to me the root of my issue
npm is trying to write to a directory it doesn't have permission to write to.
Please explain how i might be able to change my permissions
As you can read on the npm docs, if you see an EACCES error when you try to install a package globally, you can either manually change npm’s default directory or reinstall npm with a node version manager.
Change npm’s default directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
This creates a directory for global installations and configures npm to use the new directory path. Then create a ~/.profile file (or open it if one exists) and add:
export PATH=~/.npm-global/bin:$PATH
Reload your shell, then reattempt your install to check that it is working:
source ~/.profile
npm i -g create-react-native-app
Use a version manager
This is my preferred option, as you can install as many versions of Node and npm as you like and change between them at will. It also totally negates the permissions issue.
The version manager I use is nvm. To install it, there is a handy one-liner using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
To verify the install:
command -v nvm
which should output 'nvm' if the installation was successful.
There are also a bunch of other installation methods listed on the project's homepage.
Once you have it installed, you can see what versions of Node are available with:
nvm ls-remote
And install a version using:
nvm install xx.xx.xx
(where xx.xx.xx is the version number).
If you'd like to read more about using nvm, this article is helpful: Installing Multiple Versions of Node.js Using nvm.
Using sudo
You'll probably find that prefixing sudo to your command fixes the issue. However, please don't do this.
Installing random code from the internet with admin rights is a really, really bad idea.

npm permission issue on fresh install of Homestead / Vagrant / Laravel

Two days dealing with this issue and it is winning.
I have a fresh install of Windows 10 host, running the latest versions of Vagrant, laravel/homestead (Ubuntu 18.04 LTS box, v 6.0.0), Virtualbox, laravel, git for windows, node.js for windows.
vagrant, git, virtualbox are set to run as administrator in windows.
I create a Laravel project called blog like this:
vagrant#homestead:~/src$ composer create-project --prefer-dist laravel/laravel blog
All creates OK. I then try and install npm like this:
vagrant#homestead:~/src/blog$ npm install -g npm#latest
And I get:
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! path /usr/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/npm'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules/npm'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules/npm\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules/npm' }
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! /home/vagrant/.npm/_logs/2018-05-05T00_57_41_110Z-debug.log
But when i check vagrant user permissions:
vagrant#homestead:~/src/blog$ groups
vagrant adm cdrom sudo dip www-data plugdev lxd lpadmin sambashare
So I solve this with the not recommended by npm message:
vagrant#homestead:~/src/blog$ sudo npm install -g npm#latest
I now go and install an npm package like highcharts:
vagrant#homestead:~/src/blog$ npm install --save highcharts
npm WARN rollback Rolling back highcharts#6.1.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515'
npm ERR! path /home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515' -> '/home/vagrant/src/blog/node_modules/highcharts/package.json'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-05-05T01_10_24_241Z-debug.log
I try sudo to install package, same result
vagrant#homestead:~/src/blog$ sudo npm install --save --no-bin-links highcharts
npm WARN rollback Rolling back highcharts#6.1.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036'
npm ERR! path /home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036' -> '/home/vagrant/src/blog/node_modules/highcharts/package.json'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-05-05T01_58_13_140Z-debug.log
The result is a highchatrts folder in node_modules with only the packaje.json.1984492036 file in it.
I cannot seem to find a way around this. Using --no-bin-links gives the same error.
Any help is appreciated.
I got it all working by running npm install from the git host os, not from the ubuntu vm. Not what I wanted but I move forward and have learned something and creeped closer to insanity...
I had this same issue two days ago, try running sudo npm install --unsafe-perm , undo any changes you made first though, cause i don't know how valet works (sad Linux user)

NPM install fails with ETXTBSY error, text file is busy

Trying to use laravel-mix, but when i try npm install, or npm install --no-bin-links, or sudo npm install, i get this error below.. I'm on windows 8.1 using homestead and vagrant.. Please any help on this
npm WARN ETXTBSY: text file is busy, unlink '/home/vagrant/blog/mix/node_modules/abbrev/package.json.78971974'
npm ERR! path /home/vagrant/blog/mix/node_modules/acorn-dynamic-import/package.json.247239
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/blog/mix/node_modules/acorn-dynamic-import/package.json.247239' -> '/home/vagrant/blog/mix/node_modules/acorn-dynamic-import/package.json'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2017-09-04T00_51_52_140Z-debug.log
I had the same issue and couldn't get npm to work.
Try using yarn.
homestead ssh
sudo npm install -g yarn
cd blog/mix
yarn install

Unable to install Ionic with npm? (Mac OSX El Capitan 10.11.2)

I am trying to install Ionic using npm, on my mac, running OSX El Capitan 10.11.2.
sudo npm install -g cordova ionic
Cordova is already installed, and I definitely entered my password correctly. Here are the error messages and logs:
Last login: Sun May 1 18:41:17 on ttys001
egaumbp:~ gg$ sudo npm install -g cordova ionic
Password:
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
/usr/local/bin/ionic -> /usr/local/lib/node_modules/ionic/bin/ionic
> node-sass#3.4.2 install /usr/local/lib/node_modules/ionic/node_modules/node-sass
> node scripts/install.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
path.js:424
var path = (i >= 0) ? arguments[i] : process.cwd();
^
Error: EACCES: permission denied, uv_cwd
at Error (native)
at Object.posix.resolve (path.js:424:50)
at startup (node.js:96:32)
at node.js:968:3
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! node v4.4.1
npm ERR! npm v2.14.20
npm ERR! code ELIFECYCLE
npm ERR! node-sass#3.4.2 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#3.4.2 install script 'node scripts/install.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/gg/npm-debug.log
egaumbp:~ gg$
Is there a solution?
If you are having issues install Ionic, you might wanna check an article I wrote on installing it: https://medium.com/#gautham.gg/how-to-install-ionic-on-mac-without-issues-3efe92a0da93#.yh5zsay13
Here is a summary of the article:
Prerequisite: npm must be installed. You can check this by entering this command: 'npm -v'. This should give you the version number. If not please install them.
Now lets fix the issue.
First launch this command:
sudo npm install --global --unsafe-perm quickscrape
Then, launch this command:
sudo npm install -g cordova ionic --unsafe-perm quickscrape
Now, run this command:
sudo npm install -g ionic --unsafe-perm node-sass
Once I did this, Ionic worked beautifully. This was done on a MacBook Pro (Retina, 13-inch, Late 2012), running OSX El Capitan 10.11.2.
I'm not sure if Windows users have any issues with this, but I believe that you should remove the 'sudo' if you are doing this on windows.
Now that you have followed my steps, both Ionic and Cordova should be installed, and working. Start by creating a blank Ionic project:
ionic start myApp blank
no idea what 'quickscrape' (in the accepted answer) is, but the solution as given here was easier and worked for me:
sudo chown -R $USER /usr/local/
and then never use sudo again with npm.

NPM install fails

I am currently unable to install NPM on Mac OS, I have looked all over the place for someone with the same error, but I can't seem to find any. Could anyone give me a hand? This is what I get after running the curl command to install NPM:
All clean!
npm-install-94139.sh: line 302: 94407 Segmentation fault: 11 "$node" cli.js rm npm -gf
npm ERR! addLocal Could not install .
npm ERR! Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock'
npm ERR! { [Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.5.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package
npm ERR! node -v v0.8.19
npm ERR! npm -v 1.1.71
npm ERR! path /Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package/npm-debug.log
npm ERR! not ok code 0
It failed
The solution on this other question seems better than messing around with NVM - npm throws error without sudo
SOLUTION:
You need to unlock permissions in home directory, like Noah says.
sudo chown -R `whoami` ~/.npm
You also need to write it to your library as well, like Xilo says.
sudo chown -R `whoami` /usr/local/lib/node_modules
My guess is that a directory used by npm (maybe /usr/local or something in your home folder) has the wrong permissions. Installing with sudo might work now but it can also bite you later since you'll definitely create files and directories as root, possibly causing problems later when npm tries to cache things.
My advice would be to uninstall, then reinstall via nvm instead. This does a great job of managing different node versions under ~/.nvm without having to use sudo.
Try clearing npm cache with
npm cache clean
Hope that helps.
when all else fails, clear you cache
Did you try "sudo" with your curl command?
Also, if you install a new version of Node, it now includes NPM, so you don't have to even install NPM separately..
From the NPM readme file: https://npmjs.org/doc/README.html
SUPER EASY INSTALL
npm comes with node now.
Windows Computers
Get the MSI. npm is in it.
Apple Macintosh Computers
Get the pkg. npm is in it.
Other Sorts of Unices
Run make install. npm will be installed with
node.
If you want a more fancy pants install (a different version, customized paths, etc.) then read on...

Resources