npm search执行报错,npm install没问题
发布于 8 年前 作者 Erobaby 8812 次浏览 来自 问答

执行其他命令,例如 npm install 没问题,只有npm search报错是什么原因呢 ?请教一下大神。 npm-debug.log 内容如下

0 info it worked if it ends with ok 1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'search',
1 verbose cli   'birdblue' ]
2 info using npm@3.8.9
3 info using node@v6.2.0
4 silly mapToRegistry name -/all
5 silly mapToRegistry using default registry
6 silly mapToRegistry registry https://registry.npm.taobao.org/
7 silly mapToRegistry data Result {
7 silly mapToRegistry   raw: '-/all',
7 silly mapToRegistry   scope: null,
7 silly mapToRegistry   name: null,
7 silly mapToRegistry   rawSpec: '-/all',
7 silly mapToRegistry   spec: '-/all',
7 silly mapToRegistry   type: 'local' }
8 silly mapToRegistry uri https://registry.npm.taobao.org/-/all
9 info updateIndex /Users/erobaby/.npm/registry.npm.taobao.org/-/all/.cache.json
10 verbose correctMkdir /Users/erobaby/.npm correctMkdir not in flight; initializing
11 warn Building the local index for the first time, please be patient
12 silly update-index fetching https://registry.npm.taobao.org/-/all
13 verbose request uri https://registry.npm.taobao.org/-/all
14 verbose request no auth needed
15 info attempt registry request try #1 at 10:09:21 PM
16 verbose request id 42795a828884fa6f
17 http request GET https://registry.npm.taobao.org/-/all
18 http 200 https://registry.npm.taobao.org/-/all
19 verbose headers { date: 'Tue, 24 May 2016 14:09:25 GMT',
19 verbose headers   'content-type': 'application/json; charset=utf-8',
19 verbose headers   'content-length': '6353839',
19 verbose headers   connection: 'keep-alive',
19 verbose headers   etag: '"60f3af-JoOug2jyagvkE0Rh498e7g"',
19 verbose headers   'x-readtime': '4026' }
20 verbose stack Error: true true: -/all
20 verbose stack     at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:264:12)
20 verbose stack     at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:252:14)
20 verbose stack     at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:172:14)
20 verbose stack     at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:200:22)
20 verbose stack     at emitTwo (events.js:106:13)
20 verbose stack     at Request.emit (events.js:191:7)
20 verbose stack     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1067:10)
20 verbose stack     at emitOne (events.js:101:20)
20 verbose stack     at Request.emit (events.js:188:7)
20 verbose stack     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:988:12)
21 verbose statusCode 200
22 verbose cwd /Users/erobaby/Workspace/node-study
23 error Darwin 15.0.0
24 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "search" "birdblue"
25 error node v6.2.0
26 error npm  v3.8.9
27 error code E200
28 error true true: -/all
29 error If you need help, you may report this error at:
29 error     <https://github.com/npm/npm/issues>
30 verbose exit [ 1, true ]
2 回复

没有人关注这个问题吗?Github上14年就一直存在的问题,到现在貌似都还没有彻底解决。@Erobaby 楼主还在不在? 我现在npm更新到3.9.X。使用官方原来的registry,会出现JS Heap耗尽的错误,具体描述见https://github.com/npm/npm/issues/12619, 使用taobao镜像,现象和搂住相同。 根据Forrest L Norvell @othiym23 (npm负责人)的回复,这个问题出在npm-registry-client模块,拖了很久,但优先级不高一直没有解决。其实问题就是npm规模壮大太快,现在的包数量太多,npm search会试图一次全部读完所有包的索引数据,导致内存耗光。 但3.9.X版本貌似已经使用了用streaming方式读取包数据的npm-registry-client,我试了一下,try很多把能成功一把,可能是麻痹的GFW导致的吧。npm-registry-client的版本是7.1.0,需要更新一下,npm install -g npm-registry-client。如果下来发现版本不够高,就直接去github上把npm-registry-client的源码clone下来,然后用npm本地安装就好。 至于为什么taobao镜像就不行,我也搞不清楚,新手。哪位大神进来解决一下!

回到顶部