nodejs - npm install canvas error in windows

2019-05-26 07:09发布

I've installed nodejs on windows and tried adding the canvas module using the following command...

npm install canvas

I get the following error message...

'node-waf' is not regonized as an internal or external command, operable program or batch file.

Is there a way to install node-waf on windows or an alternative way to install modules?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-05-26 07:30

I have read that you should try to use Gyp instead of node-waf. It's apparently better cross platform as well.

Up to version 0.4 the node.js team offered node-waf (a waf 1.5.3 wrapper script) to configure and build modules for node.js. This was fine since in windows there was no native support and you had to use Cygwin to make your builds. From version 0.5 and on, there node supports native windows builds which brings visual studio in to play. The problem is that waf started supporting visual studio’s msbuild from version 1.6 and on and this was a major setback. In the meanwhile the node.js team decided to move on to gyp and abandoned the node-waf script. If you are tempted to create a node-waf wrapping waf 1.6, try to resist. A lot of things have changed in waf 1.6 and when I finished modifying the script, I still couldn’t generate proper windows builds (I would have to hardwire the linking arguments in order to link the object to node.lib just for windows). On the other hand, gyp supports custom arguments depending on the building platform which makes the gyp files easier to maintain.

http://botsikas.blogspot.com/2011/12/nodejs-modules-cross-platform.html

查看更多
一夜七次
3楼-- · 2019-05-26 07:33

You can also use canvas implementation based on GDI+ https://bitbucket.org/pastorgluk/node-canvas-win

查看更多
登录 后发表回答