title: Jenkin's build failing on npm install
body: <p>I'm setting up an ubuntu server that has jenkins for CI.</p>
  
  <p><em>When I try to run a build I get failure</em></p>
  
  <p><strong>Question:</strong>
  How can I make <code>npm install</code> work from my jenkins job?</p>
  
  <p><strong>build 1:</strong></p>
  
  <pre><code>[morningharwood] $ /bin/sh -xe /tmp/hudson8925730298288495807.sh
  + pwd
  /var/lib/jenkins/workspace/morningharwood
  + ls
  bower.json
  client
  e2e
  Gruntfile.js
  karma.conf.js
  package.json
  protractor.conf.js
  server
  + npm install
  /tmp/hudson8925730298288495807.sh: 5: /tmp/hudson8925730298288495807.sh: npm: not found
  Build step 'Execute shell' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p>Jenkin build
  <img src="https://i.stack.imgur.com/VEe79.png" alt="enter image description here"></p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>~$ pwd
  /home/ubuntu
  
  ls -a
  
  
  .   .bash_history  .bashrc  .config    .gem    .gnupg  .node-gyp  .nvm      .rbenv  .ssh  .viminfo
  ..  .bash_logout   .cache   .dotfiles  .gemrc  .local  .npm       .profile  .rvm    .vim
  </code></pre>
  
  <p>Now that I see the <code>.npm</code></p>
  
  <pre><code>+ /home/ubuntu/.npm/npm install
  /tmp/hudson1456103398115324880.sh: 5: /tmp/hudson1456103398115324880.sh: /home/ubuntu/.npm/npm: not found
  Build step 'Execute shell' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p><strong>Configuration Script:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/8h1jr.png" alt="enter image description here"></p>
  
  <p><strong>What happens when you run from ssh terminal?</strong></p>
  
  <pre><code>npm WARN engine karma@0.12.28: wanted: {"node":"~0.8 || ~0.10"} (current: {"node":"0.11.14","npm":"2.0.0"})
  npm ERR! Linux 3.13.0-36-generic
  npm ERR! argv "/home/ubuntu/.nvm/v0.11.14/bin/node" "/home/ubuntu/.nvm/v0.11.14/bin/npm" "install"
  npm ERR! node v0.11.14
  npm ERR! npm  v2.0.0
  npm ERR! path /var/lib/jenkins/workspace/morningharwood/node_modules
  npm ERR! code EACCES
  npm ERR! errno -13
  
  npm ERR! Error: EACCES, mkdir '/var/lib/jenkins/workspace/morningharwood/node_modules'
  ...
  </code></pre>
  
  <p>So I've CHOWN the folder:</p>
  
  <pre><code>   + pwd
      /var/lib/jenkins/workspace/morningharwood
     sudo chown ubuntu /var/lib/jenkins/workspace/morningharwood/ -Rv
     ...
  </code></pre>
  
  <p>Ran npm install after that
         npm install</p>
  
  <p>It was successful!</p>
  
  <p><strong>NEW PROBLEM:</strong>
  My build now fails when trying to clone the repository from github via jenkins. </p>
  
  <p><strong>Console log</strong></p>
  
  <pre><code>    Started by user matthew harwood
  Building in workspace /var/lib/jenkins/workspace/morningharwood
   &gt; git rev-parse --is-inside-work-tree # timeout=10
  Fetching changes from the remote Git repository
   &gt; git config remote.origin.url git@github.com:matthewharwood/morningharwood.git # timeout=10
  ERROR: Error fetching remote repo 'origin'
  ERROR: Error fetching remote repo 'origin'
  Finished: FAILURE
  </code></pre>
  
  <p><strong>Showing owners:</strong></p>
  
  <pre><code>ls -la
  drwxr-xr-x  3 jenkins jenkins 4096 Dec 26 20:31 .
  drwxr-xr-x 13 jenkins jenkins 4096 Dec 26 08:23 ..
  drwxr-xr-x  7 ubuntu  jenkins 4096 Dec 26 20:59 morningharwood
  </code></pre>