frontend:npm
差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
frontend:npm [2016/09/09 10:29] – [version] memory | frontend:npm [2023/12/03 10:24] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 33: | 行 33: | ||
<code - ~/ | <code - ~/ | ||
+ | phantomjs_cdnurl=https:// | ||
+ | sass_binary_site=https:// | ||
registry=https:// | registry=https:// | ||
+ | chromedriver_cdnurl=https:// | ||
+ | electron_mirror=https:// | ||
</ | </ | ||
行 40: | 行 44: | ||
< | < | ||
npm config set registry https:// | npm config set registry https:// | ||
+ | npm config set phantomjs_cdnurl https:// | ||
+ | npm config set sass_binary_site https:// | ||
+ | npm config set chromedriver_cdnurl https:// | ||
+ | npm config set electron_mirror https:// | ||
</ | </ | ||
- | ==== 加速phantomjs下载 ==== | + | 或者像这样直接使用: |
- | + | ||
- | phantomjs在中国大陆网络环境下下载巨慢,可以通过设置 '' | + | |
< | < | ||
- | export | + | PHANTOMJS_CDNURL=https:// |
+ | </ | ||
- | # or | + | <WRAP center round tip 60%> |
- | PHANTOMJS_CDNURL=https://cnpmjs.org/downloads | + | 如果是在 '' |
+ | </ | ||
+ | |||
+ | ===== 私有 Registry ===== | ||
+ | |||
+ | ==== Installation ==== | ||
+ | |||
+ | 安装 [[https://github.com/verdaccio/ | ||
+ | |||
+ | <code bash> | ||
+ | mkdir private-npm && cd private-npm | ||
+ | npm init -y | ||
+ | npm install | ||
+ | pm2 start -i 2 --name private-npm ./ | ||
</ | </ | ||
+ | 可选配置: | ||
+ | |||
+ | <code yaml config.yml> | ||
+ | auth: | ||
+ | htpasswd: | ||
+ | max_users: -1 # 关闭注册 | ||
+ | |||
+ | packages: | ||
+ | ' | ||
+ | access: $all | ||
+ | publish: $authenticated | ||
+ | proxy: npmjs | ||
+ | |||
+ | listen: | ||
+ | - 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | ==== Usage ==== | ||
+ | |||
+ | 私有 Registry 的使用策略有几种。 | ||
+ | |||
+ | 第一种是全量同步自 NPM Registry,此方案仅适用于搭建公共的 Registry 镜像服务。 | ||
+ | |||
+ | 第二种是仅同步使用过的 npm pacakges。 | ||
+ | |||
+ | 第三种是私有的包通过 '' | ||
+ | |||
+ | 从方便和可靠性考虑,我们在此使用第三种方案。 | ||
+ | |||
+ | 步骤如下: | ||
+ | |||
+ | 1. 注册私有 Registry 用户 | ||
+ | |||
+ | npm adduser --registry | ||
+ | |||
+ | 2. 登录私有 Registry ,并指定某个 '' | ||
+ | |||
+ | npm login --registry http:// | ||
+ | |||
+ | 3. 提交某个包到私有的 Registry: | ||
+ | |||
+ | <code json package.json> | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | 在步骤二我们已经设置了 '' |
frontend/npm.1473388168.txt.gz · 最后更改: 2023/12/03 10:24 (外部编辑)