• 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
    odejs
    ode_modules
    pm
    ode_modulespacote
    ode_modulesmake-fetch-happen
    ode_modules
    ode-fetch-npm
    ode_modulesjson-parse-helpfulerror
    ode_modulesjjulibparse.js:745:13)
    9 verbose stack     at parse (C:Program Files
    odejs
    ode_modules
    pm
    ode_modulespacote
    ode_modulesmake-fetch-happen
    ode_modules
    ode-fetch-npm
    ode_modulesjson-parse-helpfulerrorindex.js:10:13)
    9 verbose stack     at consumeBody.call.then.buffer (C:Program Files
    odejs
    ode_modules
    pm
    ode_modulespacote
    ode_modulesmake-fetch-happen
    ode_modules
    ode-fetch-npmsrcody.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:Userszh-jiDesktopCSS3_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

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

  • 相关阅读:
    string数组批量转换成Int数组
    TCP/IP 、 HTTP 、HTTPS
    静态布局、自适应布局、流式布局、响应式布局、弹性布局等的概念和区别
    Vue源码学习02 初始化模块init.js
    IOS8白屏
    VUE 源码学习01 源码入口
    http状态码
    vue全家桶(Vue+Vue-router+Vuex+axios)(Vue+webpack项目实战系列之二)
    Vue实战Vue-cli项目构建(Vue+webpack系列之一)
    module.exports,exports,export和export default,import与require区别与联系【原创】
  • 原文地址:https://www.cnblogs.com/jokerjason/p/7799213.html
Copyright © 2020-2023  润新知