我正在尝试在我的项目中使用canvas-prebuilt
。
以下是package.json
"dependencies": {
"canvas-prebuilt": "^1.6.5-prerelease.1",
"canvas-to-image-node": "^1.0.4",
"wordcloud": "^1.0.6"
},
但我遇到了这个错误:
module.js:653
return process.dlopen(module, path._makeLong(filename));
^
Error: The module '/Users/antkong/test/node_modules/canvas-prebuilt/canvas/build/Release/canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (module.js:653:18)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/antkong/test/node_modules/canvas-prebuilt/canvas/lib/bindings.js:3:18)
at Module._compile (module.js:624:30)
at Module._extensions..js (module.js:635:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/antkong/test/node_modules/babel-register/lib/node.js:152:7)
所以我尝试了这个命令npm rebuild
。我收到了这个错误:
> canvas-prebuilt@1.6.5-prerelease.1 install /Users/antkong/test/node_modules/canvas-prebuilt
> node-pre-gyp install
[canvas-prebuilt] Success: "/Users/antkong/test/node_modules/canvas-prebuilt/canvas/build/Release/canvas-prebuilt.node" is installed via remote
> canvas@1.6.7 install /Users/antkong/test/node_modules/canvas
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 522 status code downloading checksum
如何解决此问题?
我正在考虑的一个解决方案是将nodejs降级为NODE_MODULE_VERSION 57
。但是,我不知道哪个nodejs版本对应NODE_MODULE_VERSION 57
。我的节点版本目前是8.7.0
$ node --version
v8.7.0
答案 0 :(得分:0)
我所做的是在部署中打包兼容的node.exe以使其自包含是一件非常棘手的事情。 并添加一个脚本以在PATH环境变量的头部插入当前文件夹以忽略目标环境中的节点。 我正在使用Windows。