<p>I've a Nodejs app and using Babel to enable ES6 features. I can run it on local system in dev mode. I want to deploy it to Kubernetes using PM2.</p>

<p>It is giving an error when I try to run it with PM2 using process.json.</p>

<pre><code>/bin/bash:1
15:59:52 23|app   | (function (exports, require, module, __filename, __dirname) { ����
15:59:52 23|app   |                                                               ^
15:59:52 23|app   | SyntaxError: Invalid or unexpected token
15:59:52 23|app   |     at new Script (vm.js:85:7)
15:59:52 23|app   |     at createScript (vm.js:266:10)
15:59:52 23|app   |     at Object.runInThisContext (vm.js:314:10)
15:59:52 23|app   |     at Module._compile (internal/modules/cjs/loader.js:698:28)
15:59:52 23|app   |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
15:59:52 23|app   |     at Module.load (internal/modules/cjs/loader.js:630:32)
15:59:52 23|app   |     at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
15:59:52 23|app   |     at Function.Module._load (internal/modules/cjs/loader.js:562:3)
</code></pre>

<p>This is my process.json</p>

<pre><code>{
    "apps": [
        {
            "name": "app",
            "script": "./dist/bin/www.js --env production",
            "exec_mode": "cluster",
            "instances": 0,
            "max_restarts": 20,
      "env": {
          "NODE_ENV": "production"
      },
      "env_production": {
          "NODE_ENV": "production"
      }
        }
    ]
}
</code></pre>

<p>When I run this command <code>pm2 ./dist/bin/www.js --env production</code> it works fine but when I try to run it using process.json like <code>pm2 start process.json --no-daemon</code> it throws the above error.</p>

<p>I'm trying it on local system but it also happens when I deploy to gcloud using a Dockerfile with <code>kubectl</code></p>

<p>Can someone point me to the right direction where I should try to look.</p>

tmw
<p>try this process.json:</p>

<pre><code>{
    "apps": [
        {
            "name": "app",
            "script": "./dist/bin/www.js",
            "exec_mode": "cluster",
            "instances": 0,
            "max_restarts": 20,
      "env": {
          "NODE_ENV": "development"
      },
      "env_production": {
          "NODE_ENV": "production"
      }
        }
    ]
}
</code></pre>

<p>CLI:</p>

<pre><code>pm2 start process.json --no-daemon --env production
</code></pre>
