title: Docker Jenkins Pipeline install global NPM packages
body: <p>I'm new to Docker/Jenkins.</p>
  
  <p>Jenkins triggers the container via</p>
  
  <pre><code>docker run -t -d -u 995:315 -w /workspace/projectname -v /workspace/projectname:/workspace/projectname:rw,z -v /workspace/projectname@tmp:/workspace/projectname@tmp:rw,z  circleci/node:latest
  </code></pre>
  
  <p>My Pipeline</p>
  
  <pre><code>pipeline {
      agent {
          docker {
              image 'circleci/node:latest'
          }
      }
      environment { 
          HOME="."
          NPM_CONFIG_PREFIX="${pwd()}/.npm-global"
          PATH="$PATH:${pwd()}/.npm-global/bin:${pwd tmp: true}/.npm-global/bin"
      }
      stages {
          stage('NPM Config') {
              steps {
                  sh 'npm install -g @angular/cli'
                  echo "PATH is: $PATH"
                  sh '.npm-global/bin/ng version'
                  sh '/workspace/projectname/.npm-global/bin/ng version'
                  sh 'ng version'
              }
          }
      }
  }
  
  </code></pre>
  
  <p><code>echo "PATH is: $PATH"</code> prints out </p>
  
  <pre><code>PATH is: /sbin:/usr/sbin:/bin:/usr/bin;/usr/bin/;/etc/;/etc/ssh/ssh/:/workspace/projectname/.npm-global/bin:/workspace/projectname@tmp/.npm-global/bin
  </code></pre>
  
  <p>Both of these</p>
  
  <pre><code>sh '.npm-global/bin/ng version'
  sh '/workspace/projectname/.npm-global/bin/ng version'
  </code></pre>
  
  <p>do what I expect <code>sh 'ng version'</code> to do. However, <code>sh 'ng version'</code> gives me the following error</p>
  
  <pre><code>ng version
  /workspace/projectname@tmp/durable-9f9bc04a/script.sh: 2: /workspace/projectname@tmp/durable-9f9bc04a/script.sh: ng: not found
  </code></pre>
  
  <p>I'm trying to avoid having to build my own image, what would be a good next step? </p>
  
  <p>Also I would just use <code>npx</code>, but I would need to change a lot of repos and their scripts just to make this work and I would prefer to not do that.</p>
  
  <p><strong>UPDATE</strong>: It looks like the pipeline is ignoring changes the the PATH environment variable under</p>
  
  <pre><code>environment { 
     HOME="."
     NPM_CONFIG_PREFIX="${pwd()}/.npm-global"
     PATH="/foo/bar"
  }
  </code></pre>
  
  <p>Is there a special may to modify the PATH? or maybe a permission issue? </p>