title: npm install fails in Jenkins pipeline even though I configured withNpm step to use a custom .nrpmrc file
body: <p>This is my pipeline:</p>
  
  <pre><code>pipeline {
      agent any
      tools {nodejs "node10"}
  
      stages {
          stage('Build') {
              steps {
                  withNPM(npmrcConfig: 'xxx') {
                  sh "npm config ls"
                  sh "npm install"
                  sh "ng build"
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>The Jenkins server doesn't have internet connection</strong>. It must download the npm artifacts from a Nexus server.</p>
  
  <p>I have uploaded this managed file with the npm config:</p>
  
  <pre><code>registry=http://xxxx:8081/nexus/repository/central-npm-registry/
  </code></pre>
  
  <p>central-npm-registry is a proxy against the npm registry.</p>
  
  <p><strong>NOTICE:</strong> If I use this .npmrc file from my local machine it works ok.</p>
  
  <p>When building from Jenkins I see that apparently the npm config file is setup correctly but the installations fails, any clues?</p>
  
  <pre><code>Using settings config with name central-npm-registry
  A workscape local .npmrc already exists and will be overwrriten for the build.
  Writing .npmrc file: /root/.jenkins/workspace/central-npm-registry/myapp/.npmrc
  [Pipeline] {
  [Pipeline] sh
  [myapp] Running shell script
  + npm config ls
  ; cli configs
  metrics-registry = "http://xxxxx:8081/nexus/repository/central-npm-registry/"
  scope = ""
  user-agent = "npm/6.4.1 node/v11.0.0 linux x64"
  
  ; project config /root/.jenkins/workspace/central-npm-registry/myapp/.npmrc
  registry = "http://xxxxx:8081/nexus/repository/central-npm-registry/"
  
  ; node bin location = /root/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node10/bin/node
  ; cwd = /root/.jenkins/workspace/central-npm-registry/myapp
  ; HOME = /root
  ; "npm config ls -l" to show all defaults.
  
  [Pipeline] sh
  [myapp] Running shell script
  + npm install
  
  &gt; node-sass@4.10.0 install /root/.jenkins/workspace/central-npm-registry/myapp/node_modules/node-sass
  &gt; node scripts/install.js
  
  Downloading binary from https://github.com/sass/node-sass/releases/download/v4.10.0/linux-x64-67_binding.node
  Cannot download "https://github.com/sass/node-sass/releases/download/v4.10.0/linux-x64-67_binding.node": 
  
  connect ECONNREFUSED 140.82.118.3:443
  
  Hint: If github.com is not accessible in your location
        try setting a proxy via HTTP_PROXY, e.g. 
  
        export HTTP_PROXY=http://example.com:1234
  
  or configure npm proxy via
  
        npm config set proxy http://example.com:8080
  
  &gt; node-sass@4.10.0 postinstall /root/.jenkins/workspace/central-npm-registry/myapp/node_modules/node-sass
  &gt; node scripts/build.js
  
  Building: /root/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node10/bin/node /root/.jenkins/workspace/central-npm-registry/myapp/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
  gyp info it worked if it ends with ok
  gyp verb cli [ '/root/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node10/bin/node',
  gyp verb cli   '/root/.jenkins/workspace/central-npm-registry/myapp/node_modules/node-gyp/bin/node-gyp.js',
  gyp verb cli   'rebuild',
  gyp verb cli   '--verbose',
  gyp verb cli   '--libsass_ext=',
  gyp verb cli   '--libsass_cflags=',
  gyp verb cli   '--libsass_ldflags=',
  gyp verb cli   '--libsass_library=' ]
  gyp info using node-gyp@3.8.0
  gyp info using node@11.0.0 | linux | x64
  gyp verb command rebuild []
  gyp verb command clean []
  gyp verb clean removing "build" directory
  gyp verb command configure []
  gyp verb check python checking for Python executable "python2" in the PATH
  gyp verb `which` succeeded python2 /usr/bin/python2
  gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.6.6
  gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
  gyp verb get node dir no --target version specified, falling back to host node version: 11.0.0
  gyp verb command install [ '11.0.0' ]
  gyp verb install input version string "11.0.0"
  gyp verb install installing version: 11.0.0
  gyp verb install --ensure was passed, so won't reinstall if already installed
  gyp verb install version not already installed, continuing with install 11.0.0
  gyp verb ensuring nodedir is created /root/.node-gyp/11.0.0
  gyp verb created nodedir /root/.node-gyp/11.0.0
  gyp http GET https://nodejs.org/download/release/v11.0.0/node-v11.0.0-headers.tar.gz
  gyp WARN install got an error, rolling back install
  gyp verb command remove [ '11.0.0' ]
  gyp verb remove using node-gyp dir: /root/.node-gyp
  gyp verb remove removing target version: 11.0.0
  gyp verb remove removing development files for version: 11.0.0
  gyp ERR! configure error 
  gyp ERR! stack Error: connect ECONNREFUSED 104.20.23.46:443
  gyp ERR! stack     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)
  gyp ERR! System Linux 2.6.32-754.3.5.el6.x86_64
  gyp ERR! command "/root/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node10/bin/node" "/root/.jenkins/workspace/central-npm-registry/myapp/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
  gyp ERR! cwd /root/.jenkins/workspace/central-npm-registry/myapp/node_modules/node-sass
  gyp ERR! node -v v11.0.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  Build failed with error code: 1
  npm WARN lifecycle poc-polizas@0.0.0~postinstall: cannot run in wd poc-polizas@0.0.0 node node-internals-webpack.js (wd=/root/.jenkins/workspace/central-npm-registry/myapp)
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.10.0 (node_modules/node-sass):
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.10.0 postinstall: `node scripts/build.js`
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
  
  up to date in 17.414s
  [Pipeline] sh
  [myapp] Running shell script
  + ng build
  Your global Angular CLI version (7.1.4) is greater than your local
  version (7.1.0). The local Angular CLI version is used.
  
  To disable this warning use "ng config -g cli.warnings.versionMismatch false".
  
  Date: 2018-12-21T12:00:06.525Z
  Hash: 7e41e1c4bdf3d4157b68
  Time: 25382ms
  chunk {app-domain-list-list-module} app-domain-list-list-module.js, app-domain-list-list-module.js.map (app-domain-list-list-module) 46.1 kB  [rendered]
  chunk {app-domain-login-login-module} app-domain-login-login-module.js, app-domain-login-login-module.js.map (app-domain-login-login-module) 14.3 kB  [rendered]
  chunk {main} main.js, main.js.map (main) 198 kB [initial] [rendered]
  chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 410 kB [initial] [rendered]
  chunk {runtime} runtime.js, runtime.js.map (runtime) 8.91 kB [entry] [rendered]
  chunk {scripts} scripts.js, scripts.js.map (scripts) 220 kB  [rendered]
  chunk {styles} styles.js, styles.js.map (styles) 451 kB [initial] [rendered]
  chunk {vendor} vendor.js, vendor.js.map (vendor) 4.15 MB [initial] [rendered]
  
  ERROR in ./node_modules/jwa/index.js
  Module not found: Error: Can't resolve 'crypto' in '/root/.jenkins/workspace/central-npm-registry/myapp/node_modules/jwa'
  ERROR in ./node_modules/jws/lib/sign-stream.js
  Module not found: Error: Can't resolve 'stream' in '/root/.jenkins/workspace/central-npm-registry/myapp/node_modules/jws/lib'
  ERROR in ./node_modules/jws/lib/verify-stream.js
  Module not found: Error: Can't resolve 'stream' in '/root/.jenkins/workspace/central-npm-registry/myapp/node_modules/jws/lib'
  ERROR in ./node_modules/jws/lib/data-stream.js
  Module not found: Error: Can't resolve 'stream' in '/root/.jenkins/workspace/central-npm-registry/myapp/node_modules/jws/lib'
  [Pipeline] }
  [Pipeline] // withNPM
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  ERROR: Unable to notify JIRA: [403] Forbidden
  ERROR: Failed to notify JIRA at http://192.6.4.13:8080 on this builds completion -&gt; java.net.ConnectException: Conexión rehusada (Connection refused)
  ERROR: script returned exit code 1
  Finished: FAILURE
  </code></pre>