debugger not recognizing es6 server side
Application works fine with the config in npm start run from terminal. My debugger configurations is set to running npm and command start, i have set the local package.json correctly and it's using the correct node version. However, the app crashes because it doesn't recognize ES6 syntax?
In config for project javascript version is set to ES6. I have webstorm 2017.2
.get((...args) => controller.find(...args))
^^^
SyntaxError: Unexpected token ...
Please sign in to leave a comment.
Please attach screenshots of your run configuration and run console with the error (make sure that the command used to run the app is visible in run console screenshot)
Ok. What does your start script look like?
If it works in terminal, it should work just in the same way when being started from WebStorm (unless it relies on some specific environment variables only available in terminal environment): all WebStorm does is starting the chosen Node.js interpreter and passing the specified script to it, nothing more
I'm having exactly the same problem in an es6 nodejs project in intellij IDEA ultimate 2020.1
I can start the sample app from the terminal "npm start", but any method that uses the ide fails with the same errors describe by the OP.
if I use babel it works, if I write it in es5 it works.
What does your start script look like? What run configurations do you use to run your code from the IDE? Please share screenshots illustrating the issue
I think I have found the issue but I don't know how to fix it. The incorrect Node Version is being used by intellij.
I changed the start script to include the node version as follows
the output shows the following...
What is strange is the node version I am setting in the run configuration is different from the version that is printed.
The default interpreter is set to v15.4.0
The debug configuration shows the same...
and yet when I check the version of node during the start script is shows Node 10
It's strange... According to the docs (https://docs.npmjs.com/cli/v7/commands/npm-run-script):
npm runsets theNODEenvironment variable to thenodeexecutable with whichnpmis executed. Also, if the--scripts-prepend-node-pathis passed, the directory within whichnoderesides is added to thePATH. If--scripts-prepend-node-path=autois passed (which has been the default innpmv3), this is only performed when thatnodeexecutable is not found in thePATH.But in your case the executable
npmis started with (/home/mydev/.nvm/versions/node/v15.4.0/bin/node) is ignored bynpm, and not added toPATHdespite the option, andnodeis resolved fromPATHto version 10. Looks like a bug that has to be reported to https://github.com/npm/npm/issues