npm配置文件:
metrics-registry = "https://registry.npmmirror.com/"
canvas_binary_host_mirror = "https://registry.npmmirror.com/-/binary/canvas/"
chromedriver_cdnurl = "https://registry.npmmirror.com/-/binary/chromedriver/"
electron_builder_binaries_mirror = "https://registry.npmmirror.com/-/binary/electron-builder-binaries/"
electron_mirror = "https://registry.npmmirror.com/-/binary/electron/"
nodejs_org_mirror = "https://registry.npmmirror.com/-/binary/node/"
registry = "https://registry.npmmirror.com/"
sass_binary_site = "https://registry.npmmirror.com/-/binary/node-sass"
安装canvas@2.11.2时候 ,二进制安装不了,需要源码编译,node-pre-gyp install --fallback-to-build --update-binary【此参数是二进制安装不成功,转向源码编译了, windows 下除了python 环境还得需要visual studio环境】
编译源码需要python2.7的环境。源码编译的时候需要 @babel/core@7.4.0,原来package.json 里面配置的是 @babel/core@7.4.0的版本,需要升级
npm i @babel/core@7.4.0 --unsafe-perm
npm linux下默认www权限,所以root账号下编译时候需要创建的临时目录没有权限,所以后面要加上 --unsafe-perm 参数。
如果还是不行显示使用 npm install --build-from-source canvas 从源码编译
原先编译报错信息如下:
> canvas@2.11.2 install /data/project_deploy/zsztmonitor/zhitongweb/web/node_modules/canvas
> node-pre-gyp install --fallback-to-build --update-binary
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@14.15.1 (node-v83 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/data/project_deploy/zsztmonitor/zhitongweb/web/node_modules/canvas/build'
gyp WARN EACCES current user ("www") does not have permission to access the dev dir "/root/.cache/node-gyp/14.15.1"
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!