Node.js/npm/源:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 标题文本 == == 源地址 == {| class="wikitable" |- | 官方 || https://registry.npmjs.org/ |- | 淘宝 || https://registry.npm.taobao.org |- | 阿里云 || https://npm.aliyun.com/ |- | 腾讯云 || https://mirrors.cloud.tencent.com/npm/ |- | 华为云 || https://mirrors.huaweicloud.com/repository/npm/ |- | 网易 || https://mirrors.163.com/npm/ |- | 中国科学技术大学 || http://mirrors.ustc.edu.cn/ |- | 清华大学 || https://mirrors.tuna.tsinghu…”
 
Kangkk​(留言 | 贡献)
 
(未显示同一用户的5个中间版本)
第22行: 第22行:
== 工具 ==
== 工具 ==
=== registry ===
=== registry ===
{{Shc_out|<syntaxhighlight lang="bash">
npm config get registry</syntaxhighlight>|<syntaxhighlight lang="bash">
http://registry.npm.qiwoo.org/
</syntaxhighlight>|$|/home/kangkk}}


设置 registry。
{{shc|<syntaxhighlight lang="bash">
# npm config set @myco:registry http://reg.example.com
npm config set registry https://registry.npm.taobao.org</syntaxhighlight>|$|/home/kangkk}}


进行分开测试
{{shc|<syntaxhighlight lang="bash">
{{shc|<syntaxhighlight lang="bash">
npm config set registry https://registry.npm.taobao.org</syntaxhighlight>|$}}
npm config set @q:registry http://registry.npm.qiwoo.org \\
&& npm install --registry=https://registry.npmmirror.com</syntaxhighlight>|$|/home/kangkk}}


=== nrm ===
=== nrm ===
第47行: 第57行:
Registry has been set to: https://registry.npm.taobao.org/
Registry has been set to: https://registry.npm.taobao.org/
</syntaxhighlight>|kangjian@kangkk:~/github/kangkk.github.io$}}
</syntaxhighlight>|kangjian@kangkk:~/github/kangkk.github.io$}}
==== add ====
 
添加额外的源,自定义源
 
{{Shc_out|<syntaxhighlight lang="bash">
{{Shc_out|<syntaxhighlight lang="bash">
nrm add company http://registry.npm.qiwoo.org</syntaxhighlight>|<syntaxhighlight lang="bash">
nrm add company http://registry.npm.qiwoo.org</syntaxhighlight>|<syntaxhighlight lang="bash">
add registry company success
</syntaxhighlight>|$|/home/kangkk}}
==== mirror-config-china ====
{{shc|<syntaxhighlight lang="bash">
npm i -g mirror-config-china --registry=https://registry.npmmirror.com</syntaxhighlight>|$|/home/kangkk}}


    add registry company success
{{shc|<syntaxhighlight lang="bash">
</syntaxhighlight>|$|/home/kangkk}}
# 查看npm配置
npm config list
# 查看环境变量
source ~/.bashrc && env</syntaxhighlight>|$|/home/kangkk}}
 
为项目生成镜像配置文件
{{shc|<syntaxhighlight lang="bash">
mirror-config-china --registry=https://registry.npmmirror.com</syntaxhighlight>|$|/home/kangkk}}
 
== .npmrc ==
{{hc|.npmrc|<syntaxhighlight lang="text">
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org</syntaxhighlight>}}
 
根据域设置单独源
{{hc|head=.npmrc|output=<syntaxhighlight lang="text">
registry=https://registry.nlark.com/
@q:registry=http://registry.npm.qiwoo.org</syntaxhighlight>}}

2025年7月18日 (五) 19:59的最新版本

标题文本

源地址

官方 https://registry.npmjs.org/
淘宝 https://registry.npm.taobao.org
阿里云 https://npm.aliyun.com/
腾讯云 https://mirrors.cloud.tencent.com/npm/
华为云 https://mirrors.huaweicloud.com/repository/npm/
网易 https://mirrors.163.com/npm/
中国科学技术大学 http://mirrors.ustc.edu.cn/
清华大学 https://mirrors.tuna.tsinghua.edu.cn/

工具

registry

[jian@kang /home/kangkk]$
npm config get registry
http://registry.npm.qiwoo.org/

设置 registry。

/home/kangkk
# npm config set @myco:registry http://reg.example.com
npm config set registry https://registry.npm.taobao.org

进行分开测试

/home/kangkk
npm config set @q:registry http://registry.npm.qiwoo.org \\
&& npm install --registry=https://registry.npmmirror.com

nrm

npm i -g nrm
kangjian@kangkk:~/github/kangkk.github.io$
nrm ls
* npm -------- https://registry.npmjs.org/
  yarn ------- https://registry.yarnpkg.com/
  cnpm ------- http://r.cnpmjs.org/
  taobao ----- https://registry.npm.taobao.org/
  nj --------- https://registry.nodejitsu.com/
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/
kangjian@kangkk:~/github/kangkk.github.io$
nrm use taobao
Registry has been set to: https://registry.npm.taobao.org/

添加额外的源,自定义源

[jian@kang /home/kangkk]$
nrm add company http://registry.npm.qiwoo.org
add registry company success

mirror-config-china

/home/kangkk
npm i -g mirror-config-china --registry=https://registry.npmmirror.com
/home/kangkk
# 查看npm配置
npm config list
# 查看环境变量
source ~/.bashrc && env

为项目生成镜像配置文件

/home/kangkk
mirror-config-china --registry=https://registry.npmmirror.com

.npmrc

.npmrc
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org

根据域设置单独源

.npmrc
registry=https://registry.nlark.com/
@q:registry=http://registry.npm.qiwoo.org