const { createCanvas, loadImage } = require('canvas')
const sharp = require("sharp");
这是我的代码。
throw new Error(help.join('\n'));
^
Error:
Something went wrong installing the "sharp" module
The specified procedure could not be found.
\\?\C:\Users\Thaddea\Documents\ZLI\EDITS\js\fumo\node_modules\sharp\build\Release\sharp-win32-x64.node
Possible solutions:
- Install with the --verbose flag and look for errors: "npm install --ignore-scripts=false --verbose sharp"
- Install for the current runtime: "npm install --platform=win32 --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
at Object.<anonymous> (C:\Users\Thaddea\Documents\ZLI\EDITS\js\fumo\node_modules\[4msharp[24m\lib\sharp.js:30:9)
[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)[39m
[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)[39m
[90m at Module.load (node:internal/modules/cjs/loader:981:32)[39m
[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)[39m
[90m at Module.require (node:internal/modules/cjs/loader:1005:19)[39m
[90m at require (node:internal/modules/cjs/helpers:102:18)[39m
at Object.<anonymous> (C:\Users\Thaddea\Documents\ZLI\EDITS\js\fumo\node_modules\[4msharp[24m\lib\constructor.js:8:1)
[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)[39m
[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)[39m
我遇到的错误。
我尝试过:
npm install --ignore-scripts=false --verbose Sharp
npm install --platform=win32 --arch=x64 Sharp
重新安装sharp,通过npmrebuildsharp--update-binary重建sharp,重新安装canvas,通过npmrebuildcanvas--update-binary重建canvas
有什么帮助吗?
在 Windows 上,您不能同时使用 Sharp 和 Canvas,并且没有解决方法。
检查这个 --> https://github.com/lovell/sharp/issues/3007
此 Github Issue 提供了更好的历史问题分析。 https://github.com/Automattic/node-canvas/issues/930
TLDR;
根据线程和线程上的最近事件,这在 Windows 上仍然是一个问题。但黑客就是要尝试
if (process.platform === 'win32') {
require('canvas');
require('sharp');
} else {
require('sharp');
require('canvas');
}
不确定这是否有效。