在节点 JS 中使用 gm 模块时使用 NodeJS 产生 ENOENT 错误

spawn ENOENT error with NodeJS while using gm Module in node JS

我在 AWS EC2 实例上使用 Linux OS 的 gm 节点模块。我的目标是裁剪来自 S3 bucket.I 的 url 提供的图像,我正在对来自 S3 存储桶的图像 url 进行 http 请求以获取缓冲区并将缓冲区值传递给 gm模块。我的代码如下:

  gm(buffer).crop(width, height, x, y).toBuffer(imageExtension, function (err, buffer) {
            if (err) {
               //error Handling
            } else {
              //Some Logic
            }
    });

当我将缓冲区传递给 gm crop 模块时,出现 spawn ENOENT 错误。

events.js:85
throw err; // Unhandled 'error' event
      ^
Error: spawn convert ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickDomainCallback (node.js:381:11)

我参考了以下有关堆栈溢出的链接以供参考,但无法修复错误。

  1. Error: spawn ENOENT while using GM in node
  2. Node.js: Error: spawn ENOENT while using GM module
  3. spawn ENOENT error with NodeJS
  4. nodejs - Error: spawn ENOENT while adjusting image size using module gm

有人可以帮我解决这个问题吗?

为了解决这个问题,我在服务器故障

中提到了以下link

how to properly set up ImageMagick on AWS server using nodejs and express

我 运行 下面在 Amazon EC2 实例终端上给出的命令和 linux 架构的依赖项已安装在服务器上并且 gm 节点模块开始正常工作。

sudo yum install GraphicsMagick GraphicsMagick-devel ImageMagick