win7安装node-canvas出现错误:
module.js:328
throw err;
^
Error: Cannot find module '../build/Release/canvas'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\wwwroot\mobile\trunk\src\node_modules\canvas\lib\b
indings.js:3:18)
at Module._compile (module.js:398:26)
at Module._extensions..js (module.js:405:10)
at Object.require.extensions.(anonymous function) [as .js] (D:\wwwroot\mobil
e\trunk\src\node_modules\babel-register\lib\node.js:152:7)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\wwwroot\mobile\trunk\src\node_modules\canvas\lib\c
anvas.js:13:14)
at Module._compile (module.js:398:26)
at Module._extensions..js (module.js:405:10)
at Object.require.extensions.(anonymous function) [as .js] (D:\wwwroot\mobil
e\trunk\src\node_modules\babel-register\lib\node.js:152:7)
解决办法:
npm rebuild canvas
node-gyp rebuild err :
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
Canvas.cc
CanvasGradient.cc
CanvasPattern.cc
CanvasRenderingContext2d.cc
..\src\Canvas.cc(145): warning C4457: declaration of 'data' hides function para
meter [\node_modules\canvas\build\canvas.vcxproj]
..\src\Canvas.cc(141): note: see declaration of 'data'
color.cc
Image.cc
ImageData.cc
init.cc
win_delay_load_hook.c
C:\Users\sf\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\sr
c\win_delay_load_hook.c(28): warning C4055: 'type cast': from data pointer 'HMO
DULE' to function pointer 'FARPROC' [D:\wwwroot\mobile\trunk\src\node_modules\c
anvas\build\canvas.vcxproj]
C:\Users\sf\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\sr
c\win_delay_load_hook.c(31): error C2373: '__pfnDliNotifyHook2': redefinition;
different type modifiers [D:\wwwroot\mobile\trunk\src\node_modules\canvas\build
\canvas.vcxproj]
D:\Program Files\Microsoft Visual Studio 2015\VC\include\delayimp.h(134): not
e: see declaration of '__pfnDliNotifyHook2'
解决办法:
注释 "C:\Users\sf\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\sr
c\win_delay_load_hook.c" 中的 PfnDliHook __pfnDliNotifyHook2 = load_exe_hook;