Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-33698

NodeJS plugin npm install without root permissions

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • nodejs-plugin
    • None
    • Jenkins 1.652; RHEL Server 6.7 (Santiago); NodeJS plugin 0.2.1; Node version 5.x and npm version 3.x (also tried with Node 4.x and npm 2.x)

      Here is the error stack:

      npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
      npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.8
      npm ERR! Linux 2.6.32-573.18.1.el6.x86_64
      npm ERR! argv "/vol_01/sys_apps_01/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node-5.9.0/bin/node" "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node-5.9.0/bin/npm" "install"
      npm ERR! node v5.9.0
      npm ERR! npm  v3.7.3
      npm ERR! path /vol_01/sys_apps_01/jenkins/jobs/MyJob/workspace/node_modules/mkdirp
      npm ERR! code EACCES
      npm ERR! errno -13
      npm ERR! syscall access
      
      npm ERR! Error: EACCES: permission denied, access '/vol_01/sys_apps_01/jenkins/jobs/MyJob/workspace/node_modules/mkdirp'
      npm ERR!     at Error (native)
      npm ERR!  { [Error: EACCES: permission denied, access '/vol_01/sys_apps_01/jenkins/jobs/MyJob/workspace/node_modules/mkdirp']
      npm ERR!   errno: -13,
      npm ERR!   code: 'EACCES',
      npm ERR!   syscall: 'access',
      npm ERR!   path: '/vol_01/sys_apps_01/jenkins/jobs/MyJob/workspace/node_modules/mkdirp' }
      npm ERR! 
      npm ERR! Please try running this command again as root/Administrator.
      
      npm ERR! Please include the following file with any support request:
      npm ERR!     /vol_01/sys_apps_01/jenkins/jobs/MyJob/workspace/npm-debug.log
      

      "npm install" is being triggered via the pom.xml. There weren't issues with it in the past, but for some reason it's not working now. "npm install" is a local install, and should never require root permissions unless the folder it is writing to is only writable by root. I've set the "node_modules" folder so that it can be written to by anyone, and the error still persists.

          [JENKINS-33698] NodeJS plugin npm install without root permissions

          Nikolas Falco added a comment -

          The same here, issue happends wtith NodeJS >= 6.0.

          Debugging a bit the issue it's clear is in the NodeJS because since 6.x it's changed the prefix value from the local NodeJS installation folder to new one in the (/usr in linux) that obvious only root have access there.

          I found a workaround to keept global modules separated per Node version. Following this documentation after the tar.gz is installed if we put an npmrc file into lib/node_modules/npm with right prefix value works.

          Nikolas Falco added a comment - The same here, issue happends wtith NodeJS >= 6.0. Debugging a bit the issue it's clear is in the NodeJS because since 6.x it's changed the prefix value from the local NodeJS installation folder to new one in the (/usr in linux) that obvious only root have access there. I found a workaround to keept global modules separated per Node version. Following this documentation after the tar.gz is installed if we put an npmrc file into lib/node_modules/npm with right prefix value works.

          Richard Hurt added a comment -

          I just hit this same issue on a new install of Jenkins. Installing the NodeJS plugin works but I can't seem to install any global packages due to permissions issues. Are there any workarounds for this? Is someone looking at the problem?

          Thanx!
          Richard

          Richard Hurt added a comment - I just hit this same issue on a new install of Jenkins. Installing the NodeJS plugin works but I can't seem to install any global packages due to permissions issues. Are there any workarounds for this? Is someone looking at the problem? Thanx! Richard

          Nikolas Falco added a comment -

          I've posted a workaround.

          Currently I'm working on a workaround, I will post a PR

          Nikolas Falco added a comment - I've posted a workaround. Currently I'm working on a workaround, I will post a PR

          Nikolas Falco added a comment -

          There is a PR#13 for this issue.

          Nikolas Falco added a comment - There is a PR#13 for this issue.

          Nikolas Falco added a comment -

          This is the same issue of JENKINS-27170 but happens when you also have a nodejs package system in the jenkins node.
          If the NodeJS is not in the PATH variable enviroment the npm install command use the system package that try to install global packages into system directory using the jenkins user instead root.
          This bug was insidious, and I found it only because I could no reproduce anymore after removing system nodejs package. Resolving the JENKINS-27170 resolve also this.

          Nikolas Falco added a comment - This is the same issue of JENKINS-27170 but happens when you also have a nodejs package system in the jenkins node. If the NodeJS is not in the PATH variable enviroment the npm install command use the system package that try to install global packages into system directory using the jenkins user instead root. This bug was insidious, and I found it only because I could no reproduce anymore after removing system nodejs package. Resolving the JENKINS-27170 resolve also this.

            nfalco Nikolas Falco
            healforgreen For Green
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: