SyntaxError: Cannot use import statement outside a module
Just installed webstorm and adjusted settings for node.js and NPM directories but still getting this error on my import statement. What am i doing wrong please?
Please sign in to leave a comment.
anyone?
Hi there,
Based on your screenshot ... you are using Java code in a JavaScript file.... Those are 2 different languages.
You need IntelliJ IDEA for Java.
the error is thrown by Node.js interpreter because you are using java syntax in JavaScript file; this is not valid and is not supposed to work
I ran into the same issue and fixed it somehow. I have written a blog post explaining the issue and fix for it. https://xperimentalhamid.com/how-do-i/fix-cannot-use-import-statement-outside-a-module/