npm install 加速,解决github在国内访问缓慢的问题。

我从头到尾实现了一个Golang的依赖注入框架,并且集成了gin、xorm、redis、cron、消息中间件等功能;自己觉得还挺好用的,推荐给你!也欢迎一起维护!
github地址:https://github.com/gone-io/gone
文档地址:https://goner.fun/
如果可能,请帮忙在github上点个 ⭐️ ;万分感谢!!

1.使用镜像站点

1.1.获取镜像站点的地址

方法:网上自己找。

镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在):

1.2通过config命令

npm config set registry https://registry.npmmirror.com
npm info underscore (如果上面配置正确这个命令会有字符串response)

1.3命令行指定

npm --registry https://registry.npmmirror.com info underscore 

1.4编辑 ~/.npmrc 加入下面内容

registry = https://registry.npmmirror.com

2安装cnpm,使用cnpm install代替npm install

2.1使用说明

npm install -g cnpm --registry=https://registry.npmmirror.com

或者你直接通过添加 npm 参数 alias 一个新命令:

alias cnpm="npm --registry=https://registry.npmmirror.com \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"

# Or alias it in .bashrc or .zshrc
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npmmirror.com \
  --cache=$HOME/.npm/.cache/cnpm \
  --disturl=https://npm.taobao.org/dist \
  --userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc

2.2安装模块

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

cnpm install [name]

2.3同步模块

直接通过 sync 命令马上同步一个模块, 只有 cnpm 命令行才有此功能:

cnpm sync connect

### 2.4其它命令
支持 npm 除了 publish 之外的所有命令, 如:

```bash
cnpm info connect

3. 如有不明白请参考

https://cnodejs.org/topic/4f9904f9407edba21468f31e
https://npm.taobao.org/
https://cnodejs.org/topic/5338c5db7cbade005b023c98

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dapeng-大鹏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值