1

My configuration in WebStorm looks like this:

config

and it fails with

[nodemon] 1.18.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node server.js`
[nodemon] unable to run executable: "babel-node"
[nodemon] Error
    at Bus.utils.bus.on (/Users/SOME_PATH_TO_PROJECT/node_modules/nodemon/lib/nodemon.js:156:25)
    at Bus.emit (events.js:202:15)
    at ChildProcess.<anonymous> (/Users/SOME_PATH_TO_PROJECT/node_modules/nodemon/lib/monitor/run.js:143:9)
    at ChildProcess.emit (events.js:197:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:252:12)
    at onErrorNT (internal/child_process.js:427:16)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)

The latest @babel/node is installed with yarn both globally and locally (node_modules):

$ which babel-node
/usr/local/bin/babel-node

Also tried give absolute babel-node path and relative local path (targeting node_modules). No luck.

Any idea why WebStorm cannot execute the installed babel-node? Needless to say, it works in the terminal.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Diolor
  • 13,181
  • 30
  • 111
  • 179
  • can be a `$PATH` issue. Does it work if you start WebStorm from terminal (`open -a /Applications/WebStorm.app`)? – lena Mar 15 '19 at 12:32

1 Answers1

0

Apart from the issue of not found babel-node executable, I'd strongly recommend avoiding using babel-node to run/debug your code. I'd suggest using -r babel-register instead. Just create a .babelrc like

{
  "presets": ["env"]
}

and then use a configuration like the follows to run/debug your application:

enter image description here

lena
  • 90,154
  • 11
  • 145
  • 150
  • This one fails with `unable to run executable: "node"`. `node` is obviously in the $PATH, meaning that *all* executables in `--exec` cannot be resolved And if that's correct configuration in webstorm and works for you, then I am missing something more here – Diolor Mar 15 '19 at 18:22
  • sure it works for me. Did you try starting webstorm from terminal (see my comment)? – lena Mar 15 '19 at 18:34
  • yes, but no luck, with either with or without `sudo`. Global `/usr/local/bin/nodemon` also fails – Diolor Mar 15 '19 at 18:47
  • hmm.. is it specific to nodemon? what is the result of running a file with `require('child_process').exec('node somefile.js', function(error, stdout) {});` via Node.js run configuration? – lena Mar 15 '19 at 20:24
  • Finally fixed. The issue was that my node project was in a subfolder from the Webstorm opened project. Still, I don't fully understand why because the working dir was targeting the subfolder.. – Diolor Mar 16 '19 at 12:57