赞
踩
一、npm运行时配置文件.npmrc
作用:设置package.json中的依赖包的安装来源,不设置可能会因为网络问题无法下载依赖
二、配置.npmrc(设置镜像)
- // 普通包来源
- registry=https://registry.npmmirror.com
- // 设置范围包的来源,以@test开头的包从xxx那里下载
- @test:registry=xxx
-
- // 默认镜像地址
- https://registry.npmjs.org/
- // 淘宝镜像地址
- https://registry.npmmirror.com
三、各个地方的.npmrc文件的优先级
- 1、项目.npmrc文件
- 设置的位置:在项目的根目录下有个.npmrc文件
- 如何设置:在项目的根目录下新建.npmrc文件
-
- 2、用户.npmrc文件(C:Users\yp\.npmrc)-----常用
- 如何设置:npm config set registry https://registry.npmmirror.com
-
- 3、全局.npmrc文件
- 设置的位置:npm config get prefix
- 如何设置:npm config set registry xxx -g
-
- 4、npm内置.npmrc文件
- 设置的位置:which npm
- 如何设置:不推荐设置
-
- // 开发中一般会使用1、2两种情况的设置

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。