Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import node module passing subClass argument in ES6?

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.

like image 636
r0bs Avatar asked Feb 01 '16 13:02

r0bs


People also ask

Does node support ES6 import?

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.


1 Answers

Answer from @Felix Kling works:

import gm from "gm";
const im = gm.subClass({ imageMagick: true });

...using im from here on!

like image 158
r0bs Avatar answered Sep 22 '22 13:09

r0bs