网站首页 > 博客文章 正文
推荐使用 nrm 来管理镜像源。 nrm (npm registry manager ) 是 npm 的镜像源管理工具,可以很方便的在不同的下载源之间切换。
1、全局安装
npm install -g nrm
2、查看可选下载源
nrm ls
默认选项,带 * 号表示当前使用的下载源
第一次执行没有默认值
设置默认源
nrm use taobao
SUCCESS The registry has been updated to 'taobao'.
3、切换下载源
// 切换淘宝镜像
nrm use taobao
再次执行
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/
4、添加下载源
nrm add <registry-name> <registry-url>
// 示例
nrm add myRegistry http://xxxx.com
5、删除下载源
nrm del <registry-name>
// 示例
nrm del myRegistry
6、移除缓存
npm cache clean --force
7、查看版本号
查看服务器最新版本号
npm view \<package> version
查看服务器所有版本号
npm view \<package> versions
查看本地安装包版本号(需在项目目录下执行)
npm ls \<package>
查看全局安装包版本号
npm ls \<package> -g
查看npm配置信息
npm config list
; "user" config from C:\Users\hukunzhen.npmrc
cache = "D:\nodejsmodules\npm_cache"
home = "https://npmmirror.com"
prefix = "D:\nodejsmodules\npm_global"
registry = "https://registry.npmmirror.com/"
sass_binary_site = "https://cdn.npmmirror.com/mirrors/node-sass"
; node bin location = D:\XXX\node-v18.17.1\node.exe
; node version = v18.17.1
; npm local prefix = D:\XXX\vue3\vue3-vite-ts
; npm version = 10.2.0
; cwd = D:\XXX\vue3\vue3-vite-ts
; HOME = C:\Users\XXX
; Run npm config ls -l to show all defaults.
8、npm 依赖包版本号说明
~ 会匹配最近的小版本依赖包。比如~1.2.3会匹配所有1.2.x版本,但是不包括1.3.0。
^ 会匹配最新的大版本依赖包。比如^1.2.3会匹配所有1.x.x的包,包括1.3.0,但是不包括2.0.0。
* 会匹配最新发布的版本。
使用 ^ 时,有的小版本更新后会引入新的问题导致项目不稳定。建议使用 ~ 来标记版本号,这样可以保证项目不会出现大的问题,也能保证包中的小bug可以得到修复
猜你喜欢
- 2024-11-17 应用号,传统APP的革命?(应用号不存在是什么意思)
- 2024-11-17 带你重新认识身边的前端工程师(前端工程师干什么的)
- 2024-11-17 Axure有哪些鲜为人知的使用技巧?(axure详细教程)
- 2024-11-17 英特尔 Evo 认证 PC 对决 M1 Macbook:x86 生态加持,Evo 更省心
- 2024-11-17 手把手教你搭建漂亮好看的个人网站
- 2024-11-17 高保真原型应保真到什么程度?(高保真原型应保真到什么程度才能用)
- 2024-11-17 如何提高npm 下载依赖过慢的问题(npm下载包)
- 2024-11-17 Linux 下源码安装Kong(基于数据Postgres)
- 2024-11-17 NPM升级package.json中的版本号以及更换数据源
- 2024-11-17 Node实战001:Windows搭建Node开发环境
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)