2

我们使用 Nexus 3.0.1-01 代理https://registry.npmjs.org/ 我们已经配置了一个包含 npmjs.org 代理的组和我们本地托管的 npm 存储库。在本地 npm-config 中,我们将 npm 指向我们的 Nexus 作为注册表。 所有到 Internet 的连接都通过我们公司的 http(s) 代理。

当使用 Nexus 解决诸如 bower (例如 via 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 问题的提示。

任何提示表示赞赏!

4

1 回答 1

0

好的,与 IT 一起,我能够解决这个问题。

原来这是 Squid 中的一个奇怪的错误。在缓存配置进行一些更改后,解析现在可以按预期工作。

感谢所有参与的人的贡献!

于 2017-04-11T12:28:17.090 回答