修改npm源--多种方式

简介: 修改npm源--多种方式

2024年,1月22日 npm.taobao.org 域名证书已到期下线。

重置官方源

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

淘宝源,使用最新版,旧版停止了

npm config set registry https://registry.npmmirror.com

查看当前镜像源

npm config get registry

在发表npm包时,注意把源改回官方源才能发版

使用cnpm

 npm install -g cnpm --registry=https://registry.npm.taobao.org
 
 解决安装卡顿或无法安装:
 # 注册模块镜像
 npm set registry https://registry.npm.taobao.org  
  // node-gyp 编译依赖的 node 源码镜像  
 npm set disturl https://npm.taobao.org/dist 
 // 清空缓存  
 npm cache clean --force  
 // 安装cnpm  
 npm install -g cnpm --registry=https://registry.npm.taobao.org  
cnpm install xxx

如果使用nvm管理npm版本

也可以改源,下载速度会快,但要注意旧淘宝源过期了,要在

C:\Users\some8\AppData\Roaming\nvm  settings.txt文件修改,配置新的淘宝源


npm_mirror 和 node_mirror 是在配置 Node.js 和 npm(Node Package Manager)时可能用到的镜像地址变量。在中国等地区由于网络原因,为了提高包下载速度,开发者通常会设置国内的镜像源地址。


1. node_mirror: http://npmmirror.com/mirrors/node/
2. npm_mirror: http://registry.npmmirror.com/mirrors/npm/

nvm 命令配置node npm 源

1. nvm npm_mirror https://npmmirror.com/mirrors/npm/
2. 
3. nvm node_mirror https://npmmirror.com/mirrors/node/
4.

nrm

nrm 是一个 NPM 源管理器,允许你快速地在如下 NPM 源间切换:

//安装镜像源管理工具
npm install -g nrm
 
//查看当前可用镜像源
nrm ls
 
//切换到指定镜像源
nrm use taobao
 
// 增加源
nrm add  <registry> <url> [home]
 
// 删除源
nrm del <registry>
 
// 测试速度
nrm test

目录
相关文章
|
缓存 资源调度 网络架构
使用国内的npm镜像源
使用国内的npm镜像源
4028 1
|
Web App开发 域名解析 缓存
如何在 Ubuntu 20.04 上安装 Node.js 和 npm
本文我们主要为大家介绍在 Ubuntu 20.04 上安装 Node.js 和 npm 的三种不同的方式。
164231 7
如何在 Ubuntu 20.04 上安装 Node.js 和 npm
|
Docker 容器 数据格式
Docker 修改镜像源地址
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34173549/article/details/80417198 我的Docker 版本为 1.
42583 0
|
JavaScript
npm切换源,nrm安装、配置及使用
默认的npm源是国外的,速度比较慢。可以选择国内镜像,加快下载安装速度,比如我们可以切换到taobao源或者公司内部的源。
1486 1
npm切换源,nrm安装、配置及使用
|
缓存 JavaScript 前端开发
拿下奇怪的前端报错(三):npm install卡住了一个钟- 从原理搞定安装的全链路问题
本文详细分析了 `npm install` 过程中可能出现的卡顿问题及解决方法,包括网络问题、Node.js 版本不兼容、缓存问题、权限问题、包冲突、过时的 npm 版本、系统资源不足和脚本问题等,并提供了相应的解决策略。同时,还介绍了开启全部日志、使用替代工具和使用 Docker 提供 Node 环境等其他处理方法。
9620 2
|
JSON JavaScript 开发工具
NPM 使用介绍
10月更文挑战第2天
728 0
|
缓存 JavaScript Oracle
Node.js版本管理工具之NVM
Node.js版本管理工具之NVM
|
应用服务中间件 Shell 网络安全
nginx安装提示 libssl.so.3: cannot open shared object file: No
【8月更文挑战第1天】### 原因 未将安装的ssl中的`libssl.so.3`链接到`/usr/lib`导致缺失。 ### 解决方案 1. 检查openssl是否已安装,若为低版本则需重装。 ```sh whereis openssl
6042 6