James
James

Reputation: 2860

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.

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.

My file structure is as follows: enter image description here

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. The code transpiles and the application runs.

In my root folder I have the www.js file as follows:

'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:

enter image description here

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:enter image description here

Thanks

Upvotes: 0

Views: 534

Answers (1)

lena
lena

Reputation: 93848

Works for me with -r babel-register: as soon as I enter route path in browser, breakpoint is hit:

enter image description here

I's suggest creating a support ticket, providing a project that shows up the issue

Upvotes: 1

Related Questions