配置 npm 南大源
南大源采用了腾讯云和官方源的混合代理形式。
npm 配置指南
临时使用
npm install [packageName] --registry=https://repo.nju.edu.cn/repository/npm/
使用此命令可以临时使用南大源下载指定包。
设置为默认源
使用一下命令修改默认源:
npm config set registry https://repo.nju.edu.cn/repository/npm/ # 修改源
npm 私服
南京大学 npm 仓库同时提供 npm 包托管服务,本校师生可以将自己编写的 js 脚本打包后发布到仓库中让其他人使用。此仓库文件不会同步到其他镜像源。
从仓库获取文件
将上面提到的仓库地址改为 https://repo.nju.edu.cn/repository/onpm-nju/ 即可。
使用此仓库请注意:
向仓库提交文件
使用 npm 登陆:
npm adduser --registry https://repo.nju.edu.cn/repository/npm-releases/
其中,邮箱推荐使用南大邮箱,账号密码为统一身份认证账号密码。
在项目的 package.json 中加入以下内容:
"publishConfig": {
"registry" : "https://repo.nju.edu.cn/repository/npm-releases/"
},
配置 package.json 中的其他配置项。
配置 .npmignore 指定你不想发布的文件(夹)。
构建并推送:
npm run build
npm publish
yarn 配置指南
yarn config set registry https://repo.nju.edu.cn/repository/npm/ # 修改源
yarn 发布的过程和 npm 类似,不过 yarn login 的时候不需要输入密码,在每次发布的时候输入,具体内容请查看 yarn publish 的文档。