最新消息:20190529 VPS服务器已从腾讯云香港换为Vultr新加坡,主题仍用朋友推荐的大前端D8

【已解决】把npm的地址从淘宝镜像换成原始的国外地址

npm crifan 1319浏览 0评论

之前为了加速npm,所以把镜像地址换成国内的淘宝了

但是折腾:

【已解决】npm install react-native-elements出错:[server error] Cannot load the stats for react-native-elements – please try again later

期间,怀疑是国内淘宝镜像中,没有同步,缺少了:react-native-elements

所以去想办法,换回原始地址

从:

npm install taobao [server error] Cannot load the stats for

淘宝 NPM 镜像

看起来原始地址是:

npmjs.org

然后去试试search,结果search都失败:

➜  rn_rse npm search react-native-elements
npm WARN search fast search endpoint errored. Using old search.
npm WARN Failed to read search cache. Rebuilding
npm WARN Building the local index for the first time, please be patient
npm ERR! No search sources available
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/crifan/.npm/_logs/2017-10-10T08_27_54_545Z-debug.log

npm registry 淘宝 换回 国外

npm换源与恢复官方源 | FLY.Lee

此处确认之前是设置为了taobao:

➜  rn_rse npm config get registry

然后去试试:

npm config edit

结果找不到taobao的配置。

后来还是自己摸索:

npm help config

知道有list,去:

npm config list

看到了:

➜  rn_rse npm config list
; cli configs
metrics-registry = “https://registry.npm.taobao.org/”;
scope = “”
user-agent = “npm/4.6.1 node/v8.0.0 darwin x64”
; globalconfig /usr/local/etc/npmrc
disturl = “https://npm.taobao.org/dist”;
registry = “https://registry.npm.taobao.org/”;
; node bin location = /usr/local/bin/node
; cwd = /Users/crifan/dev/dev_root/xxx
; HOME = /Users/crifan
; “npm config ls -l” to show all defaults.

所以去删除:

➜  rn_rse npm config delete registry
➜  rn_rse npm config delete disturl

但是还是存在啊:

➜  rn_rse npm config list
; cli configs
metrics-registry = “https://registry.npm.taobao.org/”;
scope = “”
user-agent = “npm/4.6.1 node/v8.0.0 darwin x64”
; globalconfig /usr/local/etc/npmrc
disturl = “https://npm.taobao.org/dist”;
registry = “https://registry.npm.taobao.org/”;
; node bin location = /usr/local/bin/node
; cwd = /Users/crifan/dev/dev_root/xxx
; HOME = /Users/crifan
; “npm config ls -l” to show all defaults.

npm换源 – CSDN博客

➜  rn_rse npm config set registry https://registry.npmjs.org
➜  rn_rse npm config get registry

但是

➜  rn_rse npm config get disturl

https://npm.taobao.org/dist

所以也要去换掉

但不知道换成什么

npm disturl

快速搭建 Node.js 开发环境以及加速 npm – CNode技术社区

–disturl=http://dist.cnpmjs.org

npm original disturl

试了试:

https://dist.npmjs.org

http://dist.npmjs.org

都不行

npm disturl npmjs org

Wrong distUrl · Issue #6923 · npm/npm

Support `disturl` from npm config · Issue #363 · tj/n

npm disturl   org

npm config set disturl

npm clear  disturl

delete不掉:

  rn_rse npm config delete disturl

➜  rn_rse npm config get disturl

https://npm.taobao.org/dist

所以还是搞不定,无法删除disturl

暂时先不管了。

然后去试试:

结果不知道是不是网络原因,总之install不出来任何库

然后换回淘宝的源,结果也是同样问题。

重启mac

换回taobao的源,貌似可以install了。

但是速度还是很慢。

再去试试:

npm install react-native-elements

问题依旧:

[server error] Cannot load the stats for react-native-elements – please try again later

参考:

淘宝 NPM 镜像

npm换源 – CSDN博客

# 默认源

npm config set registry https://registry.npmjs.org

# https -> http,这样网速就会好很多

npm config set registry http://registry.npmjs.org

# 如果还不能下载,就切换成淘宝源

npm config set registry https://registry.npm.taobao.org

Yarn && npm设置镜像源 – Oreo – Medium

https://medium.com/@qjj/yarn-设置镜像源-988a90200c93

“”yarn
yarn config set registry https://registry.npm.taobao.org –global
yarn config set disturl https://npm.taobao.org/dist —global
“”npm
npm config set registry https://registry.npm.taobao.org –global
npm config set disturl https://npm.taobao.org/dist –global

在中国,安装 & 升级 npm 依赖的正确方法

“npm 默认的源为 https://registry.npmjs.org/

npmrc | npm Documentation

配置文件相关的有:

  • per-project config file (/path/to/my/project/.npmrc)

  • per-user config file (~/.npmrc)

  • global config file ($PREFIX/etc/npmrc)

  • npm builtin config file (/path/to/npm/npmrc)

抽空再去研究这些配置。

【总结】

此处,对于registry,之前就是通过:

npm config set registry https://registry.npm.taobao.org

换成淘宝的源。

此处可以通过:

npm config set registry https://registry.npmjs.org

换成官网的源的。

但是之前被设置为淘宝的disturl

(注:

npm config list

可以看到:

; globalconfig /usr/local/etc/npmrc
disturl = “https://npm.taobao.org/dist”;

暂时也没找到合适的办法清除掉。

转载请注明:在路上 » 【已解决】把npm的地址从淘宝镜像换成原始的国外地址

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
64 queries in 0.079 seconds, using 18.79MB memory