Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.56k stars 2.62k forks source link

babel-node not working when launching with ecosystem.config.js #4780

Open joeyfurness opened 4 years ago

joeyfurness commented 4 years ago

What's going wrong?

babel-node doesn't transpile properly when launching app with a config.js file. Using CLI arguments works, ex: pm2 start --interpreter babel-node app.js.

When launching from the config.js file, what's weird is that when I run pm2 info app it says that the interpreter is babel-node, however I still get errors on my ES6 syntax. When launching with CLI arguments, it appears everything is transpiling correctly and no errors are logged.

How could we reproduce this issue?

The config file I use is:

  apps : [{
    name: 'app',
    script: 'app.js',
    watch: '.',
    interpreter: '/usr/bin/babel-node',
    exec_mode: 'fork'
  }]
};

The CLI command that works as expected is pm2 start --interpreter babel-node app.js

Supporting information

$ pm2 report
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ArthurHVS commented 3 years ago

Have anything about this my friend? Stuck here also...

In my case, the services keep running (with no restarts), but logging es6 syntax errors. Pretty weird.

Occours only in an CentOS server, actually.

Mattperkinsee commented 2 years ago

I was having an issue with PM2 5.1.2 on CentOS servers as well. I was able to finally get this to work by adding

interpreter: "babel-node"

to the ecosystem.config.js file

Edit: Nevermind. I didn't notice you were already including that option. Hopefully this can help someone else with a similar issue.

ravindra21 commented 7 months ago
module.exports = {
  apps: [
    {
      name: "myapp",
      watch: true,
      script: "npx babel-node index.js", // apply babel-node
      env: {
        PORT: 3000,
        NODE_ENV: "staging",
      },
    },
  ],
};