Skip to main content

npmrc 配置文件

有些 node 模块比如 canvas、SQLite3 使用了原生 C/C++代码,需要使用源码根据实际的操作平台环境进行原生模块编译。这些情况下由于第三方的脚本会直接用国外源下载依赖,容易出现下载依赖超时的问题,所以需要手动指定对应模块的国内镜像地址来加速

registry=https://registry.npmmirror.com
# node-sass预编译二进制文件下载地址
sass_binary_site=https://registry.npmmirror.com/-/binary/node-sass
# sharp预编译共享库, 截止2022-09-20 sharp@0.31.0的预编译共享库并未同步到镜像, 入安装失败可切换到sharp@0.30.7使用
sharp_libvips_binary_host=https://registry.npmmirror.com/-/binary/sharp-libvips
python_mirror=https://registry.npmmirror.com/-/binary/python/
electron_mirror=https://registry.npmmirror.com/-/binary/electron/
electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
# 无特殊配置参考{pkg-name}_binary_host_mirror={mirror}
canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas
node_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/sqlite3
better_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3
# node 版本与 package.json 配置不同的时候,中断命令执行
engine-strict = true

注意以上配置根据具体项目需求配置就行了,不需要都带上