javascript - Node.js: Error: spawn ENOENT while using GM module - Stack Overflow

Even though this has been asked several times, none of the existing answers helped me out. Using a MEAN

Even though this has been asked several times, none of the existing answers helped me out. Using a 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 the piece of code I am 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 writing permissions were given by:

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

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

Even though this has been asked several times, none of the existing answers helped me out. Using a 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 the piece of code I am 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 writing permissions were given by:

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

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

Share Improve this question edited Nov 1, 2014 at 22:18 Igor P. asked Nov 1, 2014 at 22:09 Igor P.Igor P. 1,4773 gold badges22 silver badges37 bronze badges 4
  • Did you install imagemagick/graphicsmagick first as noted in the gm readme? If so, are you able to execute imagemagick/graphicsmagick manually from the shell prompt? – mscdex Commented Nov 1, 2014 at 22:14
  • Yes, both were installed. Sorry for asking but how can I execute it manually? – Igor P. Commented Nov 1, 2014 at 22:37
  • For graphicsmagick it's just gm. – mscdex Commented Nov 1, 2014 at 23:35
  • No, I can't start it manually. Getting the error: no such mand. Maybe I need to set a PATH? – Igor P. Commented Nov 2, 2014 at 8:57
Add a ment  | 

3 Answers 3

Reset to default 5

It is looking for the gm(GraphicsMagick) binary

Install GraphicsMagick via PPA:

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

This worked for me

This helped me solving this issue.

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 should be installed

The gm module can't find the path to the gm executable. So it sounds like your $PATH needs to be updated to include the path where graphicsmagick was installed to.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742324748a4422522.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信