当前位置:网站首页>npm 更改为淘宝镜像的方法[通俗易懂]
npm 更改为淘宝镜像的方法[通俗易懂]
2022-07-31 18:20:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
npm 更改为淘宝镜像的方法
1、命令行临时使用指定镜像(淘宝)
npm --registry https://registry.npm.taobao.org install express2、命令行永久更改使用指定镜像(淘宝)
npm config set registry https://registry.npm.taobao.org以后 npm install express 默认使用指定(淘宝)镜像
3、通过npm配置文件直接修改,本质和第2条一样,配置文件位置(windows环境)为C盘下的.npmrc文件(百度很容易查到文件路径),MAC没试过。可以用如下命令找到配置文件位置
npm config ls -l4、使用淘宝 NPM 镜像(参考 http://www.runoob.com/nodejs/nodejs-npm.html)
命令行输入
npm install -g cnpm --registry=https://registry.npm.taobao.org这样就可以使用 cnpm 命令来安装模块了: cnpm install express
查看目前使用的npm镜像的方法:
npm config get registry5、设置单独某个包的下载地址(以包electron,其镜像https://npm.taobao.org/mirrors/electron/为例,参考https://reactnative.cn/docs/debugging/)
打开.npmrc,添加该包的指定镜像,截图如下
6、要想将镜像源改回国外的源可以直接将.npmrc文件直接删除,想恢复时直接从回收站还原即可。
7、查看npm源上包的所有版本,以 babel-core 为例:
npm view babel-core versions8、安装包的最新版本,包含beta版,以 babel-core 为例:
npm install [email protected]9、查看package-lock.json中具体依赖树(以开源库tar为例):
npm ls tarnpm的缓存及全局包位置(默认情况)
可以通过命令行”npm config get cache”获取缓存目录,对于全局路径还可以用这个命令”npm root -g”
mac下: /Users/apple/.npmrc (“apple”是自己的mac用户名)
window下:%APPDATA%/npm/node_modules
npm源管理工具:
nrm:npm install -g nrm
参考:
1、https://www.jianshu.com/p/e953bd426368
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127518.html原文链接:https://javaforall.cn
边栏推荐
- Unity 之 音频类型和编码格式介绍
- 全平台GPU通用AI视频补帧超分教程
- adb shell error error: device unauthorized
- Write a database document management tool based on WPF repeating the wheel (1)
- [pytorch] pytorch automatic derivation, Tensor and Autograd
- Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)
- Automated testing - web automation - first acquaintance with selenium
- 【AcWing】第 62 场周赛 【2022.07.30】
- 华为手机一键开启“维修模式”隐藏所有数据,让手机隐私更加安全
- MySQL---多表查询
猜你喜欢
随机推荐
Flink_CDC搭建及简单使用
Three.js入门
浅谈网络安全之算法安全
【源码解析】BeanFactory和FactoryBean
Cache and Database Consistency Solutions
Unity 之 音频类型和编码格式介绍
新型电信“套路”,我爸中招了!
Istio介绍
【Yugong Series】July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
AcWing 1282. Search Keyword Problem Solution ((AC Automata) Trie+KMP)+bfs)
Go basic part study notes
Masterless replication system (2) - read and write quorum
研发过程中的文档管理与工具
微信小程序的路由拦截
MySQL common statements
Last write wins (discards concurrent writes)
iNeuOS工业互联网操作系统,设备运维业务和“低代码”表单开发工具
多数据中心操作和检测并发写入
认识异常 (看完这篇你就懂了)
LevelSequence源码分析








