【问题标题】:Nexus 3 npm proxy failing most of the timeNexus 3 npm 代理大部分时间都失败
【发布时间】:2017-02-02 08:56:00
【问题描述】:

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

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

感谢任何提示!

【问题讨论】:

  • 您使用的是什么版本的 npm/node 和操作系统?有助于我们重现问题。
  • 你能升级到最新的(3.2.0)看看你有没有这个问题?
  • 我做了一些进一步的调查。一个问题是 npm for one 不会每次都访问注册表。还有一个是npm明显缓存了一个“not found”的结果很长一段时间……每次我尝试解决都使缓存失效后,问题依然存在。解析工作两次,然后失败(404),然后工作两次,然后失败......我们使用 npm 1.3.10。这个版本不知道 no_proxy 变量,所以解析看起来像这样:npm => proxy => nexus => proxy => npmjs.org 我怀疑代理是这里的罪魁祸首......
  • @DarthHater 我现在已经进一步分析了这个问题。它会影响 all npm 2.x 版本(我们使用带有节点 4.3.2 的 npm 2.14.12)以及 all Nexus 3.x 版本。我已经针对 Nexus 2.x 和 Artifactory 5 进行了测试。两者都可以正常工作。我猜我们的内部代理是 Squid,我正在尝试从 IT 获取配置。
  • 顺便说一下,它只影响组存储库。如果我只使用一个简单的代理 repo(指向 registry.npmjs.org),它也可以工作。使用组会破坏事情,即使该组中只有(工作)代理。

标签: npm nexus nexus3


【解决方案1】:

好的,我和 IT 一起解决了这个问题。

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

感谢所有参与贡献的人!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-07
    • 2011-02-28
    相关资源
    最近更新 更多