当前位置:网站首页>npm 更改为淘宝镜像的方法[通俗易懂]
npm 更改为淘宝镜像的方法[通俗易懂]
2022-07-31 18:20:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
npm 更改为淘宝镜像的方法
1、命令行临时使用指定镜像(淘宝)
npm --registry https://registry.npm.taobao.org install express
2、命令行永久更改使用指定镜像(淘宝)
npm config set registry https://registry.npm.taobao.org
以后 npm install express 默认使用指定(淘宝)镜像
3、通过npm配置文件直接修改,本质和第2条一样,配置文件位置(windows环境)为C盘下的.npmrc文件(百度很容易查到文件路径),MAC没试过。可以用如下命令找到配置文件位置
npm config ls -l
4、使用淘宝 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 registry
5、设置单独某个包的下载地址(以包electron,其镜像https://npm.taobao.org/mirrors/electron/为例,参考https://reactnative.cn/docs/debugging/)
打开.npmrc,添加该包的指定镜像,截图如下
6、要想将镜像源改回国外的源可以直接将.npmrc文件直接删除,想恢复时直接从回收站还原即可。
7、查看npm源上包的所有版本,以 babel-core 为例:
npm view babel-core versions
8、安装包的最新版本,包含beta版,以 babel-core 为例:
npm install [email protected]
9、查看package-lock.json中具体依赖树(以开源库tar为例):
npm ls tar
npm的缓存及全局包位置(默认情况)
可以通过命令行”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
边栏推荐
- MySQL---单行函数
- 并发性,时间和相对性
- Bika LIMS open source LIMS set - use of SENAITE (detection process)
- UVM RAL模型和内置seq
- [TypeScript]OOP
- UserAgent 解析
- go mode tidy出现报错go warning “all“ matched no packages
- JD.com searches for products by keyword API
- 保证接口数据安全的10种方式
- API for JD.com to obtain historical price information of commodities
猜你喜欢
Kotlin coroutines: continuation, continuation interceptor, scheduler
Kotlin协程:续体、续体拦截器、调度器
[TypeScript]OOP
All-platform GPU general AI video supplementary frame super-score tutorial
ECCV 2022 华科&ETH提出首个用于伪装实例分割的一阶段Transformer的框架OSFormer!代码已开源!...
GP 6 overall architecture study notes
Huawei mobile phone one-click to open "maintenance mode" to hide all data and make mobile phone privacy more secure
go mode tidy出现报错go warning “all“ matched no packages
如何才能真正的提高自己,成为一名出色的架构师?
新型电信“套路”,我爸中招了!
随机推荐
Mariabackup implements incremental data backup for Mariadb 10.3
Bika LIMS open source LIMS set - use of SENAITE (detection process)
【Yugong Series】July 2022 Go Teaching Course 022-Dictionary of Go Containers
IP协议从0到1
常用的安全渗透测试工具(渗透测试工具)
无主复制系统(1)-节点故障时写DB
并发性,时间和相对性
[Source code analysis] BeanFactory and FactoryBean
Tkinter 入门之旅
TestCafe总结
Handling write conflicts under multi-master replication (3) - Convergence to a consistent state and custom conflict resolution logic
API for JD.com to obtain historical price information of commodities
Flink_CDC搭建及简单使用
Multi-datacenter operation and detection of concurrent writes
mysql的备份表的几种方法
JS基础小练习
浅谈网络安全之算法安全
基于WPF重复造轮子,写一款数据库文档管理工具(一)
Taobao/Tmall get Taobao password real url API
认识异常 (看完这篇你就懂了)