user10751590
user10751590

Reputation: 303

Getting error "EACCES: permission denied" when i install 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'

Upvotes: 21

Views: 31076

Answers (5)

Patronaut
Patronaut

Reputation: 1370

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.

changing permissions

Upvotes: 3

tetonpeaks
tetonpeaks

Reputation: 31

After clearing my Cypress cache folder with cypress clear cache I ran into this issue as well.

This is what I did:

  1. sudo rm -rf the Cypress folder in your .cache directory
  2. For me I also deleted the Cypress folder in node_modules
  3. Cleaned cache with npm cache clean --force
  4. Installed Cypress with npm install cypress --save-dev

Hope this helps!

Upvotes: 3

Gustavo Damazio
Gustavo Damazio

Reputation: 126

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"

Upvotes: 0

thisismydesign
thisismydesign

Reputation: 25072

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

Upvotes: 21

João Neves Filho
João Neves Filho

Reputation: 619

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

Upvotes: 35

Related Questions