日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

解决npm 的 shasum check failed for错误

發布時間:2023/12/9 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 解决npm 的 shasum check failed for错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用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

使用

  • 安裝后系統的 npm 會被替換了,如果你要使用原生的 npm 命令,請用 npm-original 。

  • 新的 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 lsnpm ---- 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 registriesuse Change registry to registryadd [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.cnblogs.com/yaowen/p/7127023.html,如需轉載請自行聯系原作者

    創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

    總結

    以上是生活随笔為你收集整理的解决npm 的 shasum check failed for错误的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。