安装canvas遇到的问题和运行项目遇到的报错

1.mac安装问题

1)第一步使用brew安装:brew install pkg-config cairo pango libpng jpeg giflib librsvg

        如果上面命令安装出错,可以分开安装(推荐)

        brew install pkg-config

        brew install cairo

        brew install pango

        brew install libpng

        brew install jpeg

        brew install giflib

        brew install librsvg

        具体也可以参考官网文档:

GitHub - Automattic/node-canvas: Node canvas is a Cairo backed Canvas implementation for NodeJS.Node canvas is a Cairo backed Canvas implementation for NodeJS. - GitHub - Automattic/node-canvas: Node canvas is a Cairo backed Canvas implementation for NodeJS.https://github.com/Automattic/node-canvashttps://github.com/Automattic/node-canvas/wiki/icon-default.png?t=M4ADhttps://github.com/Automattic/node-canvas/wiki/        安装完之后,可以使用命令:brew list 查看是否都已安装上

2)第二步安装canvas

        npm instal canvas

        安装完之后,使用命令:npm list 查看是否已安装上canvas

2.运行项目报错一:

Error: Cannot find module '/Users/ymxx/xx/xx/xx/node_modules/canvas'
解决方案:

将安装好的canvas(位置:usr/local/lib/node_modules/node-canvas)复制到项目下面-node_modules下面,并改名为canvas(名字与项目中一致)

3.运行项目报错二:

Error: Cannot find module '../build/Release/canvas.node'

解决方案:

在当前项目中打开终端

先执行:npm uninstall canvas

再安装:npm i canvas

安装完之后使用命令:npm list 查看是否在本项目中已安装成功

最后重新初始化:yarn install

启动项目成功!

你可能感兴趣的:(javascript,node.js,python)