Es6 Import Gives Unexpected Identifier Syntaxerror When Running On Terminal
I am new to the whole ES6 concept and I am currently trying to use the export and import modules. I have a simple code that just logs something to the console. Below are the codes
Solution 1:
For Node.js, run the script with the --experimental-modules
flag. This will allow you to use ES modules in Node.js without the need to transpile the import/export statements.
node --experimental-modules ./path/to/your.js
The error is sort of misleading because without this flag, Node is trying to parse your script as a CommonJS module instead of an ES module, which does not understand import
/export
.
Post a Comment for "Es6 Import Gives Unexpected Identifier Syntaxerror When Running On Terminal"