首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Artifactory:无法在“npmjs”找到npm存储库索引

Artifactory:无法在“npmjs”找到npm存储库索引
EN

Stack Overflow用户
提问于 2016-12-06 14:00:42
回答 1查看 738关注 0票数 2

我用的是Artifactory Pro 4.12.1。我创建了一个名为npmjs-local的本地npm存储库,一个名为npmjs-remote的远程npm存储库,以及一个名为npmjs的虚拟npm存储库,该存储库聚合了前两个repos。

然后,我将npm配置为使用Artifactory作为注册表,使用:

代码语言:javascript
复制
$ npm config set registry http://artifactory.example.org/artifactory/api/npm/npmjs

当我试图使用npm search foo搜索一个包时,我会得到以下错误:

代码语言:javascript
复制
npm WARN Building the local index for the first time, please be patient
npm ERR! registry error parsing json
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/7.2.0/bin/node" "/usr/local/bin/npm" "search" "foo"
npm ERR! node v7.2.0
npm ERR! npm  v3.10.9

npm ERR! Unexpected token C in JSON at position 0
npm ERR! Cannot find the npm repository index at 'npmjs'
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!     /Users/dserodio/npm-debug.log

我使用--loglevel verbose运行了相同的搜索,我看到“无效的JSON”来自http://artifactory.example.org/artifactory/api/npm/npmjs/-/all

代码语言:javascript
复制
Cannot find the npm repository index at 'npmjs'

编辑:既可以通过Nginx实现,也可以直接通过Artifactory实现。这是完整的HTTP响应:

代码语言:javascript
复制
$ curl -v http://artifactory.example.org:8081/artifactory/api/npm/npmjs/-/all
*   Trying 10.1.2.3...
* Connected to artifactory.example.org (10.1.2.3) port 8081 (#0)
> GET /artifactory/api/npm/npmjs/-/all HTTP/1.1
> Host: artifactory.example.org:8081
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: Artifactory/4.12.1
< X-Artifactory-Id: b0f4dd7e3f5106cd:-3efe7253:158c0a36030:-7ffd
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Tue, 06 Dec 2016 16:35:01 GMT
<
* Connection #0 to host artifactory.example.org left intact
Cannot find the npm repository index at 'npmjs'

是什么导致了这个错误?

EN

回答 1

Stack Overflow用户

发布于 2016-12-07 12:01:08

如果从未生成虚拟存储库的NPM索引,则可能发生这种情况。

解决这个问题的最佳方法是重新索引存储库,这可以使用REST来完成:

代码语言:javascript
复制
curl -uadmin:password -XPOST http://artifactory.example.org:8081/artifactory/api/npm/npmjs/reindex

REST调用将触发异步索引过程,该过程可以使用Artifactory日志文件进行监视。您应该看到这样的消息:

代码语言:javascript
复制
2016-12-07 13:11:02,455 [http-nio-8081-exec-5] [INFO ] (o.a.a.n.r.NpmRequestHelper:124) - Recalculating index for npm repository npmjs scheduled to run
2016-12-07 13:12:02,527 [art-exec-102209] [INFO ] (o.a.a.n.NpmServiceImpl:237) - Npm metadata recalculation has been started for repository 'npmjs'
2016-12-07 13:13:31,071 [art-exec-102209] [INFO ] (o.a.a.n.NpmServiceImpl:263) - Finished npm metadata recalculation for repo 'npmjs' in 1.48 minutes
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40997150

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档