使用npm安装一些包失败,类似如下报错情况:

 
 C:\Program Files\nodejs>npm update npm
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "update" "npm"
npm ERR! node v6.2.0
npm ERR! npm v2.14.19 npm ERR! shasum check failed for C:\Users\kuaima\AppData\Local\Temp\npm-18136-7181dc7d\registry.npmjs.org\npm\-\npm-4.0.5.tgz
npm ERR! Expected: a9c3c00c3c5bd6b0538c71109e019afd9d5b1403
npm ERR! Actual: 229ee9303b213d8ad584a6d4f65b971874d5b0e9
npm ERR! From: https://registry.npmjs.org/npm/-/npm-4.0.5.tgz
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! C:\Program Files\nodejs\npm-debug.log
网找到了一篇良心之作——npm install 无响应解决方案(来自体验盒子),给出了3种解决方案,均可解决 npm install 慢、npm install 无响应、npm install 无法安装的问题。

方法一:使用cnpm,用淘宝 NPM 镜像

安装

$ npm install cnpm -g --registry=https://registry.npm.taobao.org

上面这种镜像使用方式将配置写死,下次用的时候配置还在。
附:搜索镜像: http://cnpmjs.org

安装模块 | $ cnpm install [name]
从 registry.npm.taobao.org 安装所有模块. 当安装的时候发现安装的模块还没有同步过来, 淘宝 NPM 会自动在后台进行同步, 并且会让你从官方 NPMregistry.npmjs.org 进行安装. 下次你再安装这个模块的时候, 就会直接从 淘宝 NPM 安装了.

同步模块 | $ cnpm sync [moduleName]

注意:cnpm支持 npm 除了 publish 之外的所有命令,也就是不支持publish,当然这并不影响我们使用,publish时换回npm即可,这样也能解决npm install无响应的问题。

方法二:使用smart-npm,用淘宝NPM镜像

智能的 npm,让你在中国使用 npm 时,下载速度更快,使用更方便! 
由于用 npm 时,默认它会访问国外资源,所以会非常卡,有时甚至会被墙。 
smart-npm 可以在我们使用 npm install 时自动从国内的镜像下载资源,而在我们使用 npm publish 又能发布到官方的 registry 上。

安装

npm install --global smart-npm --registry=https://registry.npm.taobao.org/

如果 window 用户安装最新版本不成功的话,可以试试安装 smart-npm@1。这样做的原因是,npm 的升级使得在 mac 上无法通过 bin 别名的方式覆盖原来的 npm, 只能通过先删除原来的 npm link 文件,再创建一个新的,但这种方式在 window 上可能会有问题。 所以,如果你是 window 用户,并且通过上面脚本无法安装成功的话,可以用下面脚本再试试。

npm install --global smart-npm@1 --registry=https://registry.npm.taobao.org/

安装成功后默认会在你的 npm 用户配置文件 ~/.npmrc 中添加淘宝的 registry。

卸载

npm smart uninstall   # 2.x.x 版本的 smart-npm 在卸载前需要先执行此脚本
npm uninstall --global smart-npm

注意:如果直接执行 npm uninstall 会导致找不到 npm 文件

Mac 或 Linux 用户可以使用下面命令恢复之前备份的 npm

mv $(which npm-original) $(dirname $(which npm-original))/npm

使用

  1. 安装后系统的 npm 会被替换了,如果你要使用原生的 npm 命令,请用 npm-original 。

  2. 新的 npm 会自动根据你使用的命令切换 registry,当你使用 publish, config, adduser, star 等(click here to see more) 命令时,会强制使用官方的 registry https://registry.npmjs.org;当你使用其它命令时,都会使用淘宝的镜像https://registry.npm.taobao.org/

  • 如果要强制使用官方的 registry, 只要在命令后面加上 --npm 即可。
    比如: npm install jquery --npm,就会使用官方的 registry 去拉取 jquery。(当镜像没有及时更新时,用此会选项很有效)

  • 如果要强制使用某个 registry 时,只要在命令后面添加 registry 参数即可。
    比如:npm install jquery --registry=https://r.cnpmjs.org,就会使用你指定的 registry 去拉取 jquery。

  • 如果你想修改默认的淘宝镜像或者官方的 registry,可以在你的环境变量中添加这两个参数:NPM_OFFICIAL_REGISTRY,NPM_MIRROR_REGISTRY,以此来修改默认的官方 registry 和 淘宝镜像 registry。更多环境变量的配置请点击这里

方法三:使用nrm

nrm允许你快速地在如下 NPM 源间切换,现已支持now include: npm, cnpm, taobao,nj(nodejitsu), rednpm。注意:nrm只是一个源管理器,也不能使用publish命令。

安装

$ npm install -g nrm

示例

$ nrm ls
npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
* taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/ $ nrm use cnpm //switch registry to cnpm
Registry has been set to: http://r.cnpmjs.org/

使用

Usage: nrm [options] [command]

  Commands:

    ls                           List all the registries
use Change registry to registry
add [home] Add one custom registry
del Delete one custom registry
home [browser] Open the homepage of registry with optional browser
test [registry] Show the response time for one or all registries
help Print this help Options: -h, --help output usage information
-V, --version output the version number

增加源 | nrm add [home]
删除源 | nrm del
测试速度 | nrm test

参考
http://www.uedbox.com/npm-ins... 
http://www.uedbox.com/ https://npm.taobao.org/ 
http://qiu8310.github.io/smar... 
http://qiu8310.github.io/smar...

解决npm 的 shasum check failed for错误的更多相关文章

  1. npm 走 privoxy 代理经常出现 shasum check failed 的解决办法

    今天在下载一个比较大的项目,经常 shasum check failed ,太烦了,于是想切淘宝源,分别尝试 nrm 切换和传递 --registry ,结果都出现 Unexpected end of ...

  2. 解决启动httpd报: apr_sockaddr_info_get() failed for错误

    我测试库里 service httpd start 时报 下面错误 httpd: apr_sockaddr_info_get() failed for fengxin.wzjzt.centoshttp ...

  3. npm check failed 解决办法

    npm ERR! shasum check failed for C:\Users\MM\AppData\Local\Temp\npm-10900-415697c8\registry.npmjs.or ...

  4. Vue——解决[Vue warn]: Invalid prop: custom validator check failed for prop "index". found in错误

    Invalid prop: custom validator check failed for prop "index". 错误重现: 使用element-ui的菜单,在SubMe ...

  5. caffe运行错误: im2col.cu:61] Check failed: error == cudaSuccess (8 vs. 0) invalid device function

    错误: im2col.cu:61] Check failed: error == cudaSuccess (8 vs. 0)  invalid device function 原因:由于Makefil ...

  6. windows7下解决caffe check failed registry.count(type) == 1(0 vs. 1) unknown layer type问题

    在Windows7下调用vs2013生成的Caffe静态库时经常会提示Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer t ...

  7. vue.runtime.esm.js:593 [Vue warn]: Invalid prop: custom validator check failed for prop "value".报错解决

    在uni中使用 picker组件,一直报错 vue.runtime.esm.js:593 [Vue warn]: Invalid prop: custom validator check failed ...

  8. javamail发送邮件及错误解决方法javax.mail.AuthenticationFailedException: failed to connect, no password specified?

    javamail发送邮件及错误解决方法javax.mail.AuthenticationFailedException: failed to connect, no password specifie ...

  9. 解决npm ERR!Unexpected end of JSON input while paring near (解析附近时JSON输入意外结束)'...."^2.0.0-rc.0","glob"'等npm install错误

    摘要 最近更新了一次node,但是更新后npm的命令总是会报 npm WARN deprecated fsevents@2.0.6: Please update: there are crash fi ...

随机推荐

  1. pandas关联mysql并读写数据库

    1.代码读写mysql,必须安装关联mysql的工具 操作如下命令: sudo apt-get install mysql-server mysql-clientsudo apt-get instal ...

  2. 【markdown】图片的处理

    1st: ![tip](link) 2ed: ![tip][id] [id]:base64string 本地图片 先把本地图片文件转换成base64位编码 然后把 link 替换成生成的base64编 ...

  3. GoF23种设计模式之结构型模式之外观模式

    一.概述         为子系统中的一组接口提供一个一致的界面,外观模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 二.适用性 1.当你要为一个复杂子系统提供一个简单接口的时候.子系统 ...

  4. 让Python带你看一场唯美的横飘雪!

    “北国风光,千里冰封,万里雪飘”,这句诗描写了一句美丽肃静的风光图,恰逢昨天笔者这边也下了一场比较大的雪,要不今天就用Python带大家也来领略一次美丽的雪景? 开发环境 版本:Python3.6 系 ...

  5. Python学习笔记:wxPython(GUI图形用户界面)

    wxPython是一套基于Python的第三方GUI插件,可用Python制作丰富的图形化界面程序. 安装:pip install wxPython 或者 网站下载安装https://pypi.org ...

  6. matplotlib 设置图形大小时 figsize 与 dpi 的关系

    matplotlib 中设置图形大小的语句如下: fig = plt.figure(figsize=(a, b), dpi=dpi) 其中: figsize 设置图形的大小,a 为图形的宽, b 为图 ...

  7. python中文件操作的其他方法

    前面介绍过Python中文件操作的一般方法,包括打开,写入,关闭.本文中介绍下python中关于文件操作的其他比较常用的一些方法. 首先创建一个文件poems: p=open('poems','r', ...

  8. 转载:使用Pandas进行数据匹配

    使用Pandas进行数据匹配 本文转载自:蓝鲸的网站分析笔记 原文链接:使用Pandas进行数据匹配 目录 merge()介绍 inner模式匹配 lefg模式匹配 right模式匹配 outer模式 ...

  9. hdu 6333

    Problem Description There are n apples on a tree, numbered from 1 to n.Count the number of ways to p ...

  10. markdown快捷键

    分组 功能 操作 快捷键 设置标题 一级标题 Heading1 Ctrl+1 二级标题 Heading2 Ctrl+2 三级标题 Heading3 Ctrl+3 四级标题 Heading4 Ctrl+ ...