I apologize if this is a basic question. I am new to JavaScript and couldn't find an answer after searching.
I am trying to run the file f1.js:
import abc from "./f2.js"
console.log(abc);
The f2.js looks like this:
export let abc = 1
When I tried to run f1.js using command node f1.js
, it throw an error:
SyntaxError: Cannot use import statement outside a module
I have seen other people run multiple files in html and specify type = module. My question is, can I do this without an html file and instead run it using node?
Thanks in advance.