We're using Nexus 3.0.1-01 to proxy https://registry.npmjs.org/ We've configured a group containing the proxy to npmjs.org and our locally hosted npm repo. In the local npm-config we have pointed npm to our Nexus as registry. All connections to the internet pass our corporate http(s) proxy.
When resolving "public" dependencies like bower (e.g. via npm install -g bower
) with Nexus it will fail 8 out of 10 times. When we point to the official registry everything works fine 100% of the time.
The error looks like this:
$ npm install -g bower
npm ERR! Linux 3.13.0-107-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "bower"
npm ERR! node v4.3.2
npm ERR! npm v2.14.12
npm ERR! Cannot convert undefined or null to object
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! npm-debug.log
Looking at the debug log, we get a HTTP 404 and then a HTTP 304 and then the install fails.
2 info using npm@2.14.12
3 info using node@v4.3.2
[...]
21 http request GET http://nexus/repository/npm/bower
22 http 404 http://nexus/repository/npm/bower
23 verbose headers { date: 'Thu, 02 Feb 2017 08:32:35 GMT',
23 verbose headers server: 'Nexus/3.0.1-01 (OSS)',
23 verbose headers 'x-frame-options': 'SAMEORIGIN',
23 verbose headers 'x-content-type-options': 'nosniff',
23 verbose headers 'content-type': 'application/json',
23 verbose headers 'content-length': '37',
23 verbose headers 'x-cache': 'MISS from proxy',
23 verbose headers 'x-cache-lookup': 'HIT from proxy:3128',
23 verbose headers connection: 'keep-alive' }
24 silly get cb [ 304, undefined ]
25 verbose get saving undefined to /user/.npm/nexus/repository/npm/bower/.cache.json
26 silly addNameTag next cb for bower with tag latest
27 verbose stack TypeError: Cannot convert undefined or null to object
27 verbose stack at Function.keys (native)
27 verbose stack at installTargetsError (/usr/lib/node_modules/npm/lib/cache/add-named.js:273:24)
27 verbose stack at next (/usr/lib/node_modules/npm/lib/cache/add-named.js:94:10)
27 verbose stack at RES (/usr/lib/node_modules/npm/node_modules/inflight/inflight.js:23:14)
27 verbose stack at f (/usr/lib/node_modules/npm/node_modules/once/once.js:17:25)
27 verbose stack at fixName (/usr/lib/node_modules/npm/lib/cache/add-named.js:29:5)
27 verbose stack at saved (/usr/lib/node_modules/npm/lib/cache/caching-client.js:173:7)
27 verbose stack at /usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:210:7
27 verbose stack at FSReqWrap.oncomplete (fs.js:82:15)
Like I said, we can repeat the install a few times and eventually it will work. If we use https://registry.npmjs.org/ trough our proxy everything works fine.
We also have a Nexus 2.11.3-01 that also works just fine if we use this as npm registry (proxy).
I have searched the Sonatype JIRA but couldn't find any hints to whether this is a Nexus 3 issue or not.
Any hints are appreciated!
OK, together with IT I was able to solve this.
Turns out it was a weird bug in Squid. After some changes in the caching configuration resolving now works as expected.
Thanks everyone involved for contributing!