Node.js: Error: Call ENOENT when using GM module

Even though this has been asked multiple times, none of the existing answers worked for me. Using MEAN environment (on Mac OSX) I installed graphicsmagick using:

sudo npm install gm

      

Whenever I run the following script, I get this error:

{ [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }

      

This is part of the code I'm trying to run:

var gm = require('gm');    
//var gm = require('gm').subClass({ imageMagick: true }); //tried this one too 

    gm('./project/public/images/webshots/test1.jpg')
           .resize(320, 240)
           .write('./project/public/images/webshots/test2.jpg', function (err) {
        if (!err) console.log('done');
        if(err){
           console.log(err);   
        }
        });

      

Appropriate write permissions have been granted:

sudo chmod -R 777 ./project/public/images/webshots

      

I even tried several source / destination path combinations. What else could I have missed?

+3


source to share


3 answers


The module gm

cannot find the path to the executable file gm

. It looks like yours $PATH

needs an update to include the path where the graphical magic was installed.



0


source


It's looking for the gm binary (GraphicsMagick)

Install GraphicsMagick via PPA:



sudo add-apt-repository ppa:dhor/myway
sudo apt-get update
sudo apt-get install graphicsmagick

      

This worked for me

+5


source


This helped me solve this problem.

gm('./project/public/images/webshots/test1.jpg')
.options({imageMagick: true})
.resize(320, 240)
.write('./project/public/images/webshots/test2.jpg', function (err) {
    if (!err) console.log('done');
    if(err){
       console.log(err);   
    }
});

      

Note. imageMagick must be installed

+1


source







All Articles