Nexus 3 npm 代理大部分时间都失败
Nexus 3 npm proxy failing most of the time
我们使用 Nexus 3.0.1-01 来代理 https://registry.npmjs.org/
我们已经配置了一个组,其中包含 npmjs.org 的代理和我们本地托管的 npm 存储库。在本地 npm-config 中,我们将 npm 指向我们的 Nexus 作为注册表。
所有 互联网连接都通过我们公司的 http(s) 代理。
当使用 Nexus 解决 "public" 依赖项,如 Bower(例如通过 npm install -g bower
)时,10 次中有 8 次会失败。当我们指向官方注册表时,100% 的时间一切正常。
错误如下所示:
$ 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
查看调试日志,我们得到 HTTP 404,然后是 HTTP 304,然后安装失败。
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)
就像我说的,我们可以重复安装几次,最终它会成功。如果我们通过代理使用 https://registry.npmjs.org/ 一切正常。
我们还有一个 Nexus 2.11.3-01,如果我们将其用作 npm 注册表(代理),它也能正常工作。
我搜索了 Sonatype JIRA,但找不到任何关于这是否是 Nexus 3 问题的提示。
如有任何提示,我们将不胜感激!
好的,我和 IT 一起解决了这个问题。
事实证明这是 Squid 中的一个奇怪错误。在缓存配置中进行一些更改后,解析现在可以按预期工作。
感谢所有参与贡献的人!
我们使用 Nexus 3.0.1-01 来代理 https://registry.npmjs.org/ 我们已经配置了一个组,其中包含 npmjs.org 的代理和我们本地托管的 npm 存储库。在本地 npm-config 中,我们将 npm 指向我们的 Nexus 作为注册表。 所有 互联网连接都通过我们公司的 http(s) 代理。
当使用 Nexus 解决 "public" 依赖项,如 Bower(例如通过 npm install -g bower
)时,10 次中有 8 次会失败。当我们指向官方注册表时,100% 的时间一切正常。
错误如下所示:
$ 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
查看调试日志,我们得到 HTTP 404,然后是 HTTP 304,然后安装失败。
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)
就像我说的,我们可以重复安装几次,最终它会成功。如果我们通过代理使用 https://registry.npmjs.org/ 一切正常。
我们还有一个 Nexus 2.11.3-01,如果我们将其用作 npm 注册表(代理),它也能正常工作。
我搜索了 Sonatype JIRA,但找不到任何关于这是否是 Nexus 3 问题的提示。
如有任何提示,我们将不胜感激!
好的,我和 IT 一起解决了这个问题。
事实证明这是 Squid 中的一个奇怪错误。在缓存配置中进行一些更改后,解析现在可以按预期工作。
感谢所有参与贡献的人!