=== add at 2022.04.20 ===
- 将
mirror-config-china
改为npmmirror-config-china
npm i -g npmmirror-config-china --registry=https://registry.npmmirror.com
# 查看npm配置
npm config list
# 查看环境变量
source ~/.bashrc && env
.
.
=== old , 不要再往下阅读了,下面内容已不适用 ===
看到新闻,npm.taobao.org 将在2022年5月停用
有错误的地方希望网友们帮忙指正下面是我电脑上的,镜像调整,前后对比
- 下面是
npm config list
的输出结果:
D:\repo_yarn>npm config list
; "user" config from C:\Users\51372\.npmrc
cache = "D:\\repo_npm\\npm_cache"
chromedriver_cdnurl = "https://mirrors.huaweicloud.com/chromedriver"
chromedriver-cdnurl = "https://npm.taobao.org/mirrors/chromedriver"
couchbase-binary-host-mirror = "https://npm.taobao.org/mirrors/couchbase/v{version}"
debug-binary-host-mirror = "https://npm.taobao.org/mirrors/node-inspector"
disturl = "https://npm.taobao.org/dist"
electron_mirror = "https://npm.taobao.org/mirrors/electron/"
electron-mirror = "https://npm.taobao.org/mirrors/electron/"
flow-bin-binary-host-mirror = "https://npm.taobao.org/mirrors/flow/v"
fse-binary-host-mirror = "https://npm.taobao.org/mirrors/fsevents"
fuse-bindings-binary-host-mirror = "https://npm.taobao.org/mirrors/fuse-bindings/v{version}"
git4win-mirror = "https://npm.taobao.org/mirrors/git-for-windows"
gl-binary-host-mirror = "https://npm.taobao.org/mirrors/gl/v{version}"
grpc-node-binary-host-mirror = "https://npm.taobao.org/mirrors"
hackrf-binary-host-mirror = "https://npm.taobao.org/mirrors/hackrf/v{version}"
leveldown-binary-host-mirror = "https://npm.taobao.org/mirrors/leveldown/v{version}"
leveldown-hyper-binary-host-mirror = "https://npm.taobao.org/mirrors/leveldown-hyper/v{version}"
mknod-binary-host-mirror = "https://npm.taobao.org/mirrors/mknod/v{version}"
node-sqlite3-binary-host-mirror = "https://npm.taobao.org/mirrors"
node-tk5-binary-host-mirror = "https://npm.taobao.org/mirrors/node-tk5/v{version}"
nodegit-binary-host-mirror = "https://npm.taobao.org/mirrors/nodegit/v{version}/"
operadriver_cdnurl = "https://mirrors.huaweicloud.com/operadriver"
operadriver-cdnurl = "https://npm.taobao.org/mirrors/operadriver"
phantomjs_cdnurl = "https://mirrors.huaweicloud.com/phantomjs"
phantomjs-cdnurl = "https://npm.taobao.org/mirrors/phantomjs"
prefix = "D:\\repo_npm\\npm_global"
profiler-binary-host-mirror = "https://npm.taobao.org/mirrors/node-inspector/"
puppeteer-download-host = "https://npm.taobao.org/mirrors"
python_mirror = "https://repo.huaweicloud.com/python"
python-mirror = "https://npm.taobao.org/mirrors/python"
rabin-binary-host-mirror = "https://npm.taobao.org/mirrors/rabin/v{version}"
registry = "https://registry.npm.taobao.org/"
sass_binary_site = "https://mirrors.huaweicloud.com/node-sass"
sass-binary-site = "https://npm.taobao.org/mirrors/node-sass"
sodium-prebuilt-binary-host-mirror = "https://npm.taobao.org/mirrors/sodium-prebuilt/v{version}"
sqlite3-binary-site = "https://npm.taobao.org/mirrors/sqlite3"
store-dir = "D:/repo_npm/.pnpm-store"
utf-8-validate-binary-host-mirror = "https://npm.taobao.org/mirrors/utf-8-validate/v{version}"
utp-native-binary-host-mirror = "https://npm.taobao.org/mirrors/utp-native/v{version}"
zmq-prebuilt-binary-host-mirror = "https://npm.taobao.org/mirrors/zmq-prebuilt/v{version}"
- 下面是
yarn config list
的输出结果
D:\repo_yarn>yarn config list
yarn config v1.22.10
warning package.json: No license field
info yarn config
{
'version-tag-prefix': 'v',
'version-git-tag': true,
'version-commit-hooks': true,
'version-git-sign': false,
'version-git-message': 'v%s',
'init-version': '1.0.0',
'init-license': 'MIT',
'save-prefix': '^',
'bin-links': true,
'ignore-scripts': false,
'ignore-optional': false,
registry: 'https://registry.npm.taobao.org/',
'strict-ssl': true,
'user-agent': 'yarn/1.22.10 npm/? node/v14.15.4 win32 x64',
'cache-folder': 'D:\\repo_yarn\\cache',
'global-folder': 'D:\\repo_yarn\\global',
lastUpdateCheck: 1644491119453,
prefix: 'D:\\repo_yarn\\global'
}
info npm config
{
prefix: 'D:\\repo_npm\\npm_global',
cache: 'D:\\repo_npm\\npm_cache',
sass_binary_site: 'https://mirrors.huaweicloud.com/node-sass',
phantomjs_cdnurl: 'https://mirrors.huaweicloud.com/phantomjs',
chromedriver_cdnurl: 'https://mirrors.huaweicloud.com/chromedriver',
operadriver_cdnurl: 'https://mirrors.huaweicloud.com/operadriver',
python_mirror: 'https://repo.huaweicloud.com/python',
'store-dir': 'D:/repo_npm/.pnpm-store',
electron_mirror: 'https://npm.taobao.org/mirrors/electron/',
registry: 'https://registry.npm.taobao.org',
disturl: 'https://npm.taobao.org/dist',
'chromedriver-cdnurl': 'https://npm.taobao.org/mirrors/chromedriver',
'couchbase-binary-host-mirror': 'https://npm.taobao.org/mirrors/couchbase/v{version}',
'debug-binary-host-mirror': 'https://npm.taobao.org/mirrors/node-inspector',
'electron-mirror': 'https://npm.taobao.org/mirrors/electron/',
'flow-bin-binary-host-mirror': 'https://npm.taobao.org/mirrors/flow/v',
'fse-binary-host-mirror': 'https://npm.taobao.org/mirrors/fsevents',
'fuse-bindings-binary-host-mirror': 'https://npm.taobao.org/mirrors/fuse-bindings/v{version}',
'git4win-mirror': 'https://npm.taobao.org/mirrors/git-for-windows',
'gl-binary-host-mirror': 'https://npm.taobao.org/mirrors/gl/v{version}',
'grpc-node-binary-host-mirror': 'https://npm.taobao.org/mirrors',
'hackrf-binary-host-mirror': 'https://npm.taobao.org/mirrors/hackrf/v{version}',
'leveldown-binary-host-mirror': 'https://npm.taobao.org/mirrors/leveldown/v{version}',
'leveldown-hyper-binary-host-mirror': 'https://npm.taobao.org/mirrors/leveldown-hyper/v{version}',
'mknod-binary-host-mirror': 'https://npm.taobao.org/mirrors/mknod/v{version}',
'node-sqlite3-binary-host-mirror': 'https://npm.taobao.org/mirrors',
'node-tk5-binary-host-mirror': 'https://npm.taobao.org/mirrors/node-tk5/v{version}',
'nodegit-binary-host-mirror': 'https://npm.taobao.org/mirrors/nodegit/v{version}/',
'operadriver-cdnurl': 'https://npm.taobao.org/mirrors/operadriver',
'phantomjs-cdnurl': 'https://npm.taobao.org/mirrors/phantomjs',
'profiler-binary-host-mirror': 'https://npm.taobao.org/mirrors/node-inspector/',
'puppeteer-download-host': 'https://npm.taobao.org/mirrors',
'python-mirror': 'https://npm.taobao.org/mirrors/python',
'rabin-binary-host-mirror': 'https://npm.taobao.org/mirrors/rabin/v{version}',
'sass-binary-site': 'https://npm.taobao.org/mirrors/node-sass',
'sodium-prebuilt-binary-host-mirror': 'https://npm.taobao.org/mirrors/sodium-prebuilt/v{version}',
'sqlite3-binary-site': 'https://npm.taobao.org/mirrors/sqlite3',
'utf-8-validate-binary-host-mirror': 'https://npm.taobao.org/mirrors/utf-8-validate/v{version}',
'utp-native-binary-host-mirror': 'https://npm.taobao.org/mirrors/utp-native/v{version}',
'zmq-prebuilt-binary-host-mirror': 'https://npm.taobao.org/mirrors/zmq-prebuilt/v{version}'
}
Done in 0.11s.
以下是 mirror-config-china
github主页 https://github.com/gucong3000/mirror-config-china/blob/master/README.md 上的描述:
{bin-mirrors}
{apt-mirrors}
{ali-mirrors}
--registry=https://registry.npm.taobao.org
registry.npmjs.com 镜像URL
--bin-mirrors-prefix=https://npm.taobao.org/mirrors
npm.taobao.org/mirrors 镜像URL,会覆盖下文中的{bin-mirrors}
--apt-mirrors-prefix=https://mirrors.tuna.tsinghua.edu.cn
mirrors.tuna.tsinghua.edu.cn 镜像URL,会覆盖下文中的{apt-mirrors}
--ali-mirrors-prefix=https://mirrors.aliyun.com
mirrors.aliyun.com 镜像URL,会覆盖下文中的{ali-mirrors}
阿里云ECS VPC或经典网络用户请分别使用http://mirrors.cloud.aliyuncs.com或http://mirrors.aliyuncs.com代替
--nodejs-org-mirror={bin-mirrors}/node (别名: --disturl)
nodejs.org/dist 镜像URL
--iojs-org-mirror={bin-mirrors}/iojs
iojs.org/dist 镜像URL
--nvmw-npm-mirror={bin-mirrors}/npm
github.com/npm/npm/releases 镜像URL
--apt-mirror={ali-mirrors}
Debian/Ubuntu APT镜像URL
--apt-gitlab-runner={apt-mirrors}/gitlab-runner/{release-id}
GitLab Runner APT镜像URL
--apt-docker-ce={ali-mirrors}/docker-ce/linux/{release-id}
Docker社区版 APT镜像URL
--apt-gitlab-ce={apt-mirrors}/gitlab-ce/{release-id}
GitLab社区版 APT镜像URL
--apt-virtualbox={apt-mirrors}/virtualbox/apt
VirtualBox APT镜像URL
--apt-nodesource={apt-mirrors}/nodesource/deb
NodeJS APT镜像URL前缀
现在时间(2022年2月18日 18:23:27),在使用
yarn
时出现
Done in 0.14s.
info There appears to be trouble with your network connection. Retrying...
- 使用
yarn config get registry
输出如下信息:
D:\repos_vue_ssr\ssr-demo>yarn config get registry
warning ..\..\package.json: No license field
https://registry.npm.taobao.org/
warning ..\..\package.json: No license field
可能是外层目录有package.json
文件,或者根目录下有package.json
文件,将其删除即可!使用下面命令改为新的域名
yarn config set registry https://registry.npmmirror.com
但是,切换过并不能改变
info There appears to be trouble with your network connection. Retrying...
的输出…… (这是什么原因,还得继续寻找把所有的带taobao.org
前缀的指向都修改为新的npmmirror.com
指向后,就没有再出现了)列出一个完整的切换命令
yarn config set registry https://registry.npmmirror.com
npm config set registry https://registry.npmmirror.com
yarn config get registry
npm config get registry
yarn global remove mirror-config-china
npm uninstall mirror-config-china -g
npm i -g mirror-config-china --registry=https://registry.npmmirror.com --bin-mirrors-prefix=https://npmmirror.com/mirrors
npm i -g mirror-config-china --registry=https://registry.npmmirror.com --bin-mirrors-prefix=https://npmmirror.com/mirrors
yarn global remove mirror-config-china
npm uninstall mirror-config-china -g
npm i -g mirror-config-china --registry=https://registry.npmmirror.com --bin-mirrors-prefix=https://npmmirror.com/mirrors
- 运行上面三句,特别是最后一句,并不能改变
npm config list
的显示, -
还需要删除C:\Users\51372\.npmrc
文件中的一些内容,然后再全局安装mirror-config-china
- 不行,按照上面的方式,
C:\Users\51372\.npmrc
文件还是没有变化,仍然是https://npm.taobao.org
的前缀
- 不行,按照上面的方式,
- 看来目前我只能全局替换
C:\Users\51372\.npmrc
这个文件了。【自己手动修改】
E:\wxg\test>npm config list
; "user" config from C:\Users\51372\.npmrc
- ☀🌙⭐手动替换后的文件内容如下:
- 有些是有问题的,比如
puppeteer-download-host=https://npmmirror.com/mirrors
这个就找不到 - 出了问题再调整吧
prefix=D:\repo_npm\npm_global
cache=D:\repo_npm\npm_cache
sass_binary_site=https://mirrors.huaweicloud.com/node-sass
phantomjs_cdnurl=https://mirrors.huaweicloud.com/phantomjs
chromedriver_cdnurl=https://mirrors.huaweicloud.com/chromedriver
operadriver_cdnurl=https://mirrors.huaweicloud.com/operadriver
python_mirror=https://repo.huaweicloud.com/python
store-dir=D:/repo_npm/.pnpm-store
registry=https://registry.npmmirror.com
disturl=https://npmmirror.com/mirrors/node
chromedriver-cdnurl=https://npmmirror.com/mirrors/chromedriver
couchbase-binary-host-mirror=https://npmmirror.com/mirrors/couchbase/v{version}
debug-binary-host-mirror=https://npmmirror.com/mirrors/node-inspector
electron-mirror=https://npmmirror.com/mirrors/electron/
flow-bin-binary-host-mirror=https://npmmirror.com/mirrors/flow/v
fse-binary-host-mirror=https://npmmirror.com/mirrors/fsevents
fuse-bindings-binary-host-mirror=https://npmmirror.com/mirrors/fuse-bindings/v{version}
git4win-mirror=https://npmmirror.com/mirrors/git-for-windows
gl-binary-host-mirror=https://npmmirror.com/mirrors/gl/v{version}
grpc-node-binary-host-mirror=https://npmmirror.com/mirrors
hackrf-binary-host-mirror=https://npmmirror.com/mirrors/hackrf/v{version}
leveldown-binary-host-mirror=https://npmmirror.com/mirrors/leveldown/v{version}
leveldown-hyper-binary-host-mirror=https://npmmirror.com/mirrors/leveldown-hyper/v{version}
mknod-binary-host-mirror=https://npmmirror.com/mirrors/mknod/v{version}
node-sqlite3-binary-host-mirror=https://npmmirror.com/mirrors
node-tk5-binary-host-mirror=https://npmmirror.com/mirrors/node-tk5/v{version}
nodegit-binary-host-mirror=https://npmmirror.com/mirrors/nodegit/v{version}/
operadriver-cdnurl=https://npmmirror.com/mirrors/operadriver
phantomjs-cdnurl=https://npmmirror.com/mirrors/phantomjs
profiler-binary-host-mirror=https://npmmirror.com/mirrors/node-inspector/
puppeteer-download-host=https://npmmirror.com/mirrors
python-mirror=https://npmmirror.com/mirrors/python
rabin-binary-host-mirror=https://npmmirror.com/mirrors/rabin/v{version}
sass-binary-site=https://npmmirror.com/mirrors/node-sass
sodium-prebuilt-binary-host-mirror=https://npmmirror.com/mirrors/sodium-prebuilt/v{version}
sqlite3-binary-site=https://npmmirror.com/mirrors/sqlite3
utf-8-validate-binary-host-mirror=https://npmmirror.com/mirrors/utf-8-validate/v{version}
utp-native-binary-host-mirror=https://npmmirror.com/mirrors/utp-native/v{version}
zmq-prebuilt-binary-host-mirror=https://npmmirror.com/mirrors/zmq-prebuilt/v{version}
End