I am writing some Javascript code. I created a js file which contain my exports. However, when I import it into the other js file, I get an error which says SyntaxError: Cannot use import statement outside a module.
I am using WebStorm. Here is the code:
exports(math.js).
export var add=function (n1,n2) { return n1 + n2; };
export var subtract=function (n1,n2) { return n1 - n2; };
export var multiply=function (n1,n2) { return n1 * n2; };
export var divide=function (n1,n2) { return n1 / n2; };
import import * as math from './math';
console.log(math.add(2,2)); console.log(math.subtract(2,2)); console.log(math.multiply(2,2)); console.log(math.divide(2,2));