I have some js code that wants to be imported using ES6 import syntax
import crazymodule from 'crazymodule';
How do I convert this to nodejs require
syntax?
I've tried:
const crazymodule = require('crazymodule')
I have some js code that wants to be imported using ES6 import syntax
import crazymodule from 'crazymodule';
How do I convert this to nodejs require
syntax?
I've tried:
const crazymodule = require('crazymodule')
I'd been googling for the answer for this for a while and didn't hit a good answer so I made this one to help future peeps using the same search terms as me.
That answer is you need to have .default on the end of the require line:
const crazymodule = require('crazymodule').default