Use ES6 'import' instead of 'require' in microservices framework for Node.js

1k views Asked by At

I am using moleculer microservices framework for Node.js. Now, I need to use ES6 import instead of require.

For Example,

const { abc } = require("../../index.js"); **// This is working well.** <br>
import { abc } from "../../index.js";      **// This isn't working and throw the error.**

I am getting error like Unexpected token import. I've installed Babel(JavaScript compiler) as well.

Do you have any idea about this?

Thanks,

0

There are 0 answers