0

I've tried everything in the docs but nothing seems to work. When I manage to run the interpreter with babel-node then the following error occurs uncaughtException: process.send is not a function.

With the following configuration the interpreter is not working:

ecosystem.config.js

module.exports = [{
script: './app.js',
ignore_watch:[
  "node_modules",
  "docker"
],
name: 'tower-defense',
interpreter: 'node_modules/@babel/node/bin/babel-node.js',
watch: true,
max_memory_restart: "150M",
error_file: 'logs/error.log',
out_file: 'logs/output.log',
wait_ready: true,
listen_timeout: 10000,
}, {
  script: './app.js',
  name: 'Tower Defense'
}]

I've also tried with

pm2-runtime start --watch --interpreter babel-node ecosystem.config.js app.js

pm2-runtime start ecosystem.config.js --watch --interpreter babel-node app.js

pm2-runtime start ecosystem.config.js --watch --interpreter ./node_modules/@babel/node/bin/babel-node.js app.js

and many more variants, but nothing seems to work. I always get the following error:

import Application from './core/application';
^^^^^^

SyntaxError: Cannot use import statement outside a module

When I finally got it to work it was with:

"scripts": {
    "dev": "pm2-runtime start npm -- run test ecosystem.config.js",
    "test": "babel-node app.js"
},

But then I've got the following error:

uncaughtException: process.send is not a function.

Just nothing seems to work. If someone can explain me how to properly do this I will be very grateful.

My docker setup for the process:

Dockerfile

FROM node:latest

WORKDIR /var/www/tower-defense
COPY . /var/www/tower-defense

RUN npm install -g babel-cli && npm install pm2 -g && npm install
CMD ["npm", "run", "dev"]

EXPOSE 4000
Kristian Vasilev
  • 504
  • 8
  • 26

1 Answers1

0

I've managed to make it work with

FROM node:latest

WORKDIR /var/www/tower-defense
COPY . /var/www/tower-defense

RUN npm install -g @babel/cli && npm install pm2 -g && npm install
CMD ["pm2-runtime", "ecosystem.config.js", "app.js"]

EXPOSE 4000

and the following config

module.exports = [{
    script: './app.js',
    ignore_watch: [
      "node_modules",
      "docker",
      "logs",
      ".history"
    ],
    exec_interpreter: '/var/www/tower-defense/node_modules/@babel/node/bin/babel-node.js',
    name: 'tower-defense',
    watch: true,
    max_memory_restart: "150M",
    error_file: 'logs/error.log',
    out_file: 'logs/output.log',
    wait_ready: true,
    listen_timeout: 10000,
    name: 'Tower Defense'
}]
Kristian Vasilev
  • 504
  • 8
  • 26