1

I'm trying to use this package gm from node that also require that I require fs on the top. It was giving me some error but I fix it adding this configuration to my webpack.config file:

node: {
    fs: "empty",
    child_process: "empty"
}

After adding this a new warning show up:

Module not found: Error: Cannot resolve module 'spawn-sync' in and directory path.

And when I use the crop function of this library I get TypeError: cp.spawn is not a function the code that I use is:

gm("The path to the picture")
      .crop(2574, 1872, 279, 567)
      .write("path and name of the new file", (err) => {
        if (!err) console.log("done");
        if (err) console.log(err);
      });

Now I'm using this in react, and its running in electron. Is there anything wrong with the code ? or is anything I can do to make it work ?

All I'm trying to do is crop a picture giving the start point and the are that i want to crop.

thoer metn
  • 61
  • 2
  • 1
    `npm install spawn-sync` and retry ? – Steeve Pitis Oct 05 '16 at 14:21
  • @SteevePitis Thank you I try to do it but after I install that package it made me install spawn-sync try-thread-sleep aws-sdk module tls net tap console this packages now It trow me this error: `Module build failed: Error: ENOENT: no such file or directory, open 'main directory/node_modules/spawn-sync/index.js' at Error (native)` – thoer metn Oct 05 '16 at 14:36
  • weird, kill electron and rebuild it ? – Steeve Pitis Oct 05 '16 at 14:38
  • @SteevePitis It work but now It have more warnings and I try to install the packages but still give me the same Issue. I have install so far `spawn-sync try-thread-sleep aws-sdk module tls net tap console directory node-gyp npm file` and I have errors like: `Module not found: Error: Cannot resolve 'file' or 'directory'` and `WARNING in /main dir/~/try-thread-sleep/~/thread-sleep/index.js Critical dependencies: ` – thoer metn Oct 05 '16 at 14:47

0 Answers0