npm install mongoose错误解决

Posted JokerJason

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了npm install mongoose错误解决相关的知识,希望对你有一定的参考价值。

今天安装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错误解决的主要内容,如果未能解决你的问题,请参考以下文章

npm install mongoose 导致 gyp 和 kerberos 错误(未找到 gssapi/gssapi.h 文件)

npm install 错误 安装 chromedriver 失败的解决办法

markdown 安装npm install -g出现错误解决方法

Mac环境下执行npm install报权限错误解决办法

npm install 给出错误:EPERM,取消链接

npm install时报错 npm ERR!Windows_NT 6.1.7601