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?

0
4 comments
Avatar
Permanently deleted user

anyone?

0

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.

1

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

0
Avatar
Permanently deleted user

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/ 

0

Please sign in to leave a comment.