如何使用WebStorm调试ES6 NodeJS?

即使我使用babel,我仍在尝试调试Node.js ES6服务器,但我收到此警告:

(node:17736) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. 
Please use `node --inspect` or `node --inspect-brk` instead.

Process finished with exit code 9

有人可以帮我解决这个问题吗?我看到了很多与此有关的问题,但是它们似乎都比较老,不能用于最新版本的nodejs。

这是我的配置:

如何使用WebStorm调试ES6 NodeJS?

wzqzl 回答:如何使用WebStorm调试ES6 NodeJS?

似乎使用的{em> Node.js 版本babel-node不接受--debug-brk选项,并且Webstorm无法检测到什么 Node.js 版本正在使用(通常会检查选择为 Node解释器: Node.js 的版本,并在运行时使用适当的选项)。

请选择 Node.js 可执行文件而不是那里的babel-node,并在运行配置中使用--require @babel/register作为 Node参数:以获取ES6代码即时编译:

enter image description here

当然,您需要确保安装相应的模块并相应地设置.babelrc

package.json:

"dependencies": {
  "@babel/cli": "^7.2.3","@babel/core": "^7.4.0","@babel/preset-env": "^7.4.2","@babel/register": "^7.4.0",...
}

.babelrc:

{
  "presets": [
    [
      "@babel/preset-env"
    ]
  ]
}
,

对我有用的东西

使用nodemon 添加了运行/调试NPM配置,该配置运行此脚本"dev": "nodemon"

本文链接:https://www.f2er.com/3121051.html

大家都在问