简体   繁体   English

使用Babel为Koa / Node / js应用程序进行WebStorm调试配置

[英]WebStorm Debug configuration for Koa/Node/js application using babel

I am currently trying to set up a run configuration for a Koa NodeJS application I am building within WebStorm in order to get debugging functionality and am not having any success. 我目前正在尝试为在WebStorm中构建的Koa NodeJS应用程序设置运行配置,以获取调试功能,但没有成功。

I can get the main app.js file to stop at breakpoints when I star the run configuration but when I attempt to debug basic routes the breakpoints never get hit. 启动运行配置时,可以使主app.js文件在断点处停止,但在尝试调试基本路由时,断点永远不会命中。

My file structure is as follows: 我的文件结构如下: 在此处输入图片说明

My ES6, pre-transpiled code sits in the 'src' folder and once transpiled it gets output into the 'build' folder.This is working correctly and has no issues. 我的ES6预先编译的代码位于``src''文件夹中,一旦被编译,它将输出到``build''文件夹中。这可以正常工作并且没有问题。 The code transpiles and the application runs. 代码转储,应用程序运行。

In my root folder I have the www.js file as follows: 在我的根文件夹中,具有www.js文件,如下所示:

'use strict';

const env = process.env.NOD_ENV || 'development';
const port = process.env.PORT || 4341;
const src = env === 'production' ? './build/app' : './src/app';

require('babel-polyfill');
if(env === 'development') {
    require('babel-register');
}

const app = require(src).default;
app.listen(port);

Which defines whether the application is in production or development and then starts the app accordingly. 定义应用程序是在生产中还是在开发中,然后相应地启动该应用程序。 Here is my run configuration which should debug the application: 这是我的运行配置,应该调试应用程序:

在此处输入图片说明

When this run config is stared, any breakpoints that are initially defined run correctly but are not triggered when triggering events from the browser, such as a route function etc. Can anyone see why my configuration is not working correctly or suggest other ideas? 当启动该运行配置时,最初定义的任何断点都可以正常运行,但在触发浏览器事件(例如路由功能等)时不会触发。有人能看到我的配置为什么不能正常工作或提出其他想法吗?

Edit: I have changed my run configuration to the following which still is not working: 编辑:我已将我的运行配置更改为仍然无法运行的以下配置: 在此处输入图片说明

Thanks 谢谢

Works for me with -r babel-register : as soon as I enter route path in browser, breakpoint is hit: 使用-r babel-register为我工作:在浏览器中输入路由路径后,就会遇到断点:

在此处输入图片说明

I's suggest creating a support ticket, providing a project that shows up the issue 我建议创建一个支持票,提供一个显示问题的项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM