I am getting this error SyntaxError: Cannot use import statement outside a module
when trying to import from another javascript file. This is the first time I'm trying something like this. The main file is main.js
and the module file is mod.js
.
main.js:
import * as myModule from "mod";
myModule.func();
mod.js:
export function func(){
console.log("Hello World");
}
How can I fix this? Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…