I had the same problem with php storm. Here's how I solved it:
1. First you will need to install NodeJS in order to work properly with js files in PHP storm; Download and install it on your PC from here: https://nodejs.org/en/
2. (OPTIONAL) You will need to check node js version in cmd by typing node -v it will show you the ltest version of NODE JS
3. Configure PHP storm IDE to work properly with NodeJS:
Starting to write our code you can see that the "let" statement is marked as incorrect - this happens because you haven’t set up the Language Level of our project to EcmaScript 6 (EcmaScript 6 is the reason why you need NODE JS(and not only) for phpstrom)
You may need to repeat this process for the current Settings as well
If you want to test our code locally with Node (the console we are talking about), you need to add an extra line to call the function you just wrote with some sample input and then choose Run from the Right-Click menu.
4. Watch the video below to see clearly how it is done. It is in some foreign language - but you can mute it and just watch the first 70-80 seconds: