Debug NodeJS + ES6 app (Webstorm)

后端 未结 4 1093
别跟我提以往
别跟我提以往 2020-12-28 20:09

I want to use ES6 at both: client and server side. Of course, I can launch my NodeJS server from terminal like babel-node src/app.js, but it makes it impossible

4条回答
  •  青春惊慌失措
    2020-12-28 20:39

    Finally I found the answer here. I did npm install babel and add require('babel/register') at the beginning of my main node file (app.js).

    Now I really can launch/debug Node app written with ES6 from Webstorm. But that debugging is something very strange - looks like code that worked before doesn't work know. The Intellij debuger says all my variables are undefined. Also there is an article about another possible problems.

    Example:enter image description here

    What is supper fancy about it that inside loop for (var i = 1; i < trs.length; i++) { variable i considered undefined!

提交回复
热议问题