如何在Windows上安装节点js canvas

ven*_*163 14 javascript windows canvas cairo node.js

我正在尝试在节点js上使用canvas.我正在使用Windows Vista.基本方法npm install canvas失败后(见下面的错误),我已经查了一些教程,这是我尝试过的:

来源:
安装-node-canvas-for-windows
LearnBoost/node-canvas/wiki /安装--- Windows

登录控制台(npm install canvas在cmd中运行之后):
log包含几个警告,我不是这些问题 - 它主要是'从double转换为float',以及一个标记为红色的错误:

init.cc
d:\pathToApp\node_modules\canvas\src\PNG.h(5): fatal error C1083: Cannot
open include file: 'cairo.h': No such file or directory [d:\pathToApp\n
ode_modules\canvas\build\canvas.vcxproj]
Run Code Online (Sandbox Code Playgroud)

在日志的最后有:

gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:
12)
gyp ERR! System Windows_NT 6.0.6002
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd d:\pathToApp\node_modules\canvas
gyp ERR! node -v v0.10.16
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
Run Code Online (Sandbox Code Playgroud)

之后,node-module文件夹中没有出现任何内容(没有canvas子目录,安装失败后npm删除了子目录).

所以我也尝试从github手动下载canvas模块,在节点模块中解压缩,然后node-gyp configure在node-modules/canvas中成功运行node-gyp build,这不幸地给了我同样的错误Cannot open include file: 'cairo.h'.

我仔细阅读了我在此发现的所有内容.如果您能提出任何帮助,请执行此操作.

And*_*ndy 1

经过漫长的艰苦过程,我设法在 Windows 上运行它。我有最后几条建议,你可以尝试一下我的清单上的建议。

将所有 dll 文件从 c:\GTK 复制到 canvas\build\Release 文件夹。

将 IEShims.dll 从 c:\program files(x86)\Internet Explorer 复制到 canvas\build\Release 文件夹。

然后运行node-gyp构建。

祝你好运。