码迷,mamicode.com
首页 > 其他好文 > 详细

npm install mongoose错误解决

时间:2017-11-07 16:28:48      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:from   技术分享   编辑   ada   print   conf   inter   建议   npm   

今天安装mongoose一直报错,上图

技术分享

具体的错误记录:

0 info it worked if it ends with ok
1 verbose cli [ C:\\Program Files\\nodejs\\node.exe,
1 verbose cli   C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js,
1 verbose cli   install,
1 verbose cli   mongoose ]
2 info using npm@5.3.0
3 info using node@v8.4.0
4 verbose npm-session 96143bef79c692fb
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/mongoose 1340ms (from cache)
8 silly fetchPackageMetaData error for mongoose@latest Unexpected end of input at 1:144240
8 silly fetchPackageMetaData rectories":{"lib":"./lib/mongoose"},"dist":{"shasum":"e7a1fcb9c35f29d
8 silly fetchPackageMetaData                                                                      ^
9 verbose stack SyntaxError: Unexpected end of input at 1:144240
9 verbose stack rectories":{"lib":"./lib/mongoose"},"dist":{"shasum":"e7a1fcb9c35f29d
9 verbose stack                                                                      ^
9 verbose stack     at Object.parseJSON (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\node_modules\jju\lib\parse.js:745:13)
9 verbose stack     at parse (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\index.js:10:13)
9 verbose stack     at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
9 verbose stack     at <anonymous>
9 verbose stack     at process._tickCallback (internal/process/next_tick.js:188:7)
10 verbose cwd C:\Users\zh-ji\Desktop\CSS3_yhdljm(jb51.net)\CSS3_yhdljm
11 verbose Windows_NT 10.0.15063
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "mongoose"
13 verbose node v8.4.0
14 verbose npm  v5.3.0
15 error Unexpected end of input at 1:144240
15 error rectories":{"lib":"./lib/mongoose"},"dist":{"shasum":"e7a1fcb9c35f29d
15 error                                                                      ^
16 verbose exit [ 1, true ]

 

看下面,发现是npm 的 shasum check failed,查资料发现,可能是因为NPM未更换国内淘宝镜像所致....换一下

镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在):

1.通过config命令

npm config set registry http://registry.cnpmjs.org 
npm info underscore (如果上面配置正确这个命令会有字符串response)

2.命令行指定

npm --registry http://registry.cnpmjs.org info underscore 
 

3.编辑 ~/.npmrc 加入下面内容

registry = http://registry.cnpmjs.org

 

我选用了第一种方法,然后成功安装。

技术分享

技术分享

npm install mongoose错误解决

标签:from   技术分享   编辑   ada   print   conf   inter   建议   npm   

原文地址:http://www.cnblogs.com/jokerjason/p/7799213.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!