In JS I require in the node module gm (which I want to use with imageMagick rather than the default graphicsMagick) while passing an argument like this:
var gm = require('gm').subClass({ imageMagick: true });
How can I do that in ES6?
import gm from "gm";
gm.subClass({ imageMagick: true });
doesn't work, because gm
defaults to GraphicsMagick which isn't installed.
The syntax for importing modules in ES6 looks like this. The reason for this error is that Node js doesn't support ES6 import directly. If you try to use import for importing modules directly in node js it will throw out that error.
Answer from @Felix Kling works:
import gm from "gm";
const im = gm.subClass({ imageMagick: true });
...using im
from here on!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With