2

I have the following a simple sudo npm install which keeps on failing on EACCESS error:

enter image description here

I have already tried the following on the server:

sudo chown -R jenkins /var/lib/jenkins/workspace/
sudo setfacl -R -m user:jenkins:rwx /var/lib/jenkins/workspace

But unfortunetly nothing seems to work.

Would love to hear some suggestions for what might cause the problem.

Thanks

Matan Kadosh
  • 1,669
  • 3
  • 18
  • 24
  • See if this addresses your issue:https://stackoverflow.com/questions/46859018/cannot-install-node-sass-therefore-cannot-install-gulp-sass – Derek Brown Oct 23 '17 at 15:27
  • It concerns more with global npm packages. In my case this is a local npm package trying to be written into a jenkins owned directory. – Matan Kadosh Oct 23 '17 at 15:30
  • Check if this can help you => https://stackoverflow.com/questions/40553395/error-eacces-permission-denied-rmdir-on-jenkins – David R Oct 23 '17 at 15:46

4 Answers4

5

Actually, what helped me use Jenkins with sudo rights for Ubuntu Linux was the following command:

sudo chown -R jenkins folderName
sudo setfacl -R -m user:jenkins:rwx folderName

also you need to browse to the Jenkins install in Ubuntu at

/var/lib/jenkins/workspace

Assuming you're in Home folder, you'll have to go down two levels.

cd ..
cd ..

then

cd /var/lib/jenkins/workspace

then

sudo chown -R jenkins folderName
sudo setfacl -R -m user:jenkins:rwx folderName

This fixed my "run jenkins as root" problem.

sdet.ro
  • 317
  • 3
  • 12
1

Update the .npm-global to the proper owner. I had a similar issue while deploying using Jenkins. The .npm-global folder owner was Jenkins but all the subfolder under that had root as owner. Then I changed the owner using the below command

sudo chown -R ubuntu:ubuntu .npm-global
Jérémie Bertrand
  • 3,025
  • 3
  • 44
  • 53
1

In my case, this issue appeared in combination with docker images while building. I had to set the npm_config_cache=npm-cache and HOME=. environment variables so npm uses the current directory to build.

Jenkinsfile:

docker.withRegistry('https://my_registry/', 'docker_user') {
    docker.image('node-agent:node-14').inside {
        withEnv([
            /* Override the npm cache directory */
            /* Reset Home dir */
            'npm_config_cache=npm-cache',
            'HOME=.',
        ]) {
            stage('NPM Build') {
                sh "rm -rf node_modules || true" // removing node_modules if existing.
                sh 'npm install'
                sh 'npm run build'
            }
        }
    }
}
Rapalagui
  • 79
  • 2
  • 11
0

It doesn't look like your question is a duplicate, but people have problems with installing node-sass.

The easiest way to fix your specific problem is:

sudo npm install --unsafe-perm node-sass
Steven McConnon
  • 2,650
  • 2
  • 16
  • 21