NPM安装不使用代理后面的神器

时间:2015-02-23 11:14:10

标签: node.js npm artifactory

我已将artifactory和npm配置为在代理后面工作:

npm config set registry http://myserver:8081/artifactory/api/npm/npmjs

当我致电npm info bower时,它工作正常,但tarball网址看起来很可疑:{ tarball: 'http://myserver:8081/artifactory/api/npm/npmjs/registry.npmjs.org/bower/-/bower-1.3.12.tgz', shasum: '37de0edb3904baf90aee13384a1a379a05ee214c' }

由于错误的tarball URL,

npm install bower失败。这是我的npm-debug.log的相关输出:

34 silly mapToRegistry registry http://myserver:8081/artifactory/api/npm/npmjs
35 silly mapToRegistry uri http://myserver:8081/artifactory/api/npm/npmjs/bower
36 verbose addRemoteTarball http://myserver:8081/artifactory/api/npm/npmjs/registry.npmjs.org/bower/-/bower-1.3.12.tgz not in flight; adding
37 verbose addRemoteTarball [ 'http://myserver:8081/artifactory/api/npm/npmjs/registry.npmjs.org/bower/-/bower-1.3.12.tgz',
37 verbose addRemoteTarball   '37de0edb3904baf90aee13384a1a379a05ee214c' ]
38 info retry fetch attempt 1 at 11:39:11
39 info attempt registry request try #1 at 11:39:11
40 http fetch GET http://myserver:8081/artifactory/api/npm/npmjs/registry.npmjs.org/bower/-/bower-1.3.12.tgz
41 http fetch 404 http://myserver:8081/artifactory/api/npm/npmjs/registry.npmjs.org/bower/-/bower-1.3.12.tgz
42 error fetch failed http://myserver:8081/artifactory/api/npm/npmjs/registry.npmjs.org/bower/-/bower-1.3.12.tgz

网址中的registry.npmjs.org部分是错误的,正确的tarball网址应该是这个:http://myserver:8081/artifactory/api/npm/npmjs/bower/-/bower-1.3.12.tgz。从这个URL我可以使用curl手动下载tarball。

任何想法,如果我配置错误或某处有错误?

Artifactory v3.4.2,npm v2.5.1

3 个答案:

答案 0 :(得分:1)

当应该代理npmjs注册表的远程存储库指向错误的URL(例如http://registry.npmjs com 而不是.org)时,可能会发生这种情况。

答案 1 :(得分:0)

您的Artifactory前端显示npm config

的正确字符串

这与您的跑步相匹配吗?

我看起来像这样

#Add this registry URL to your ~/.npmrc or use:
npm config set registry http://serverName:8081/artifactory/api/npm/npmjs

我只是想知道Artifactory中远程仓库的配置是否正确

另一种选择是尝试在npm远程仓库

上切换缓存

Artifactory系统日志中是否有任何信息显示它试图做什么?

答案 2 :(得分:0)

当包具有引用npmjs.org的包锁文件时,我遇到此问题。例如,像这样的文件:https://github.com/mckn/gulp-nuget/blob/master/npm-shrinkwrap.json

我想唯一的解决方案是在包锁文件的已解析字段中使用相对URL。