title: Node.js: Error: spawn ENOENT while using GM module
body: <p>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: </p>
  
  <pre><code>sudo npm install gm
  </code></pre>
  
  <p>Whenever I run the following script, I get this error: </p>
  
  <pre><code>{ [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
  </code></pre>
  
  <p>This is the piece of code I am trying to run: </p>
  
  <pre><code>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);   
          }
          });
  </code></pre>
  
  <p>Appropriate writing permissions were given by: </p>
  
  <pre><code>sudo chmod -R 777 ./project/public/images/webshots
  </code></pre>
  
  <p>I even tried several source/destination path combinations. What else could I have missed?</p>