pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

File ecosystem.config.js malformated

Open louisbrulenaudet opened this issue 2 years ago • 5 comments

Using this simple config in my ecosystem.config.js :

module.exports = { apps : [{ script: 'app.js', watch: '.' }] };

I have the following error :

[PM2][ERROR] File ecosystem.config.js malformated TypeError: Cannot convert undefined or null to object at Common.parseConfig (/Users/louisbrulenaudet/.yarn/berry/cache/pm2-npm-5.3.0-910c0e1105-9.zip/node_modules/pm2/lib/Common.js:316:26) at API._startJson (/Users/louisbrulenaudet/.yarn/berry/cache/pm2-npm-5.3.0-910c0e1105-9.zip/node_modules/pm2/lib/API.js:934:25) at API.start (/Users/louisbrulenaudet/.yarn/berry/cache/pm2-npm-5.3.0-910c0e1105-9.zip/node_modules/pm2/lib/API.js:329:12) at /Users/louisbrulenaudet/.yarn/berry/cache/pm2-npm-5.3.0-910c0e1105-9.zip/node_modules/pm2/lib/binaries/CLI.js:290:13 at /Users/louisbrulenaudet/.yarn/berry/cache/async-npm-3.2.4-aba13508f9-9.zip/node_modules/async/internal/withoutIndex.js:8:40 at replenish (/Users/louisbrulenaudet/.yarn/berry/cache/async-npm-3.2.4-aba13508f9-9.zip/node_modules/async/internal/eachOfLimit.js:81:17) at /Users/louisbrulenaudet/.yarn/berry/cache/async-npm-3.2.4-aba13508f9-9.zip/node_modules/async/internal/eachOfLimit.js:86:9 at eachLimit (/Users/louisbrulenaudet/.yarn/berry/cache/async-npm-3.2.4-aba13508f9-9.zip/node_modules/async/forEachLimit.js:47:43) at awaitable (/Users/louisbrulenaudet/.yarn/berry/cache/async-npm-3.2.4-aba13508f9-9.zip/node_modules/async/internal/awaitify.js:13:28) at Command. (/Users/louisbrulenaudet/.yarn/berry/cache/pm2-npm-5.3.0-910c0e1105-9.zip/node_modules/pm2/lib/binaries/CLI.js:289:7)

I use Node 20.6.0 with Yarn berry.

louisbrulenaudet avatar Oct 25 '23 11:10 louisbrulenaudet

Did you try renaming the file to .cjs? ecosystem.config.cjs

drijnkels avatar Oct 27 '23 20:10 drijnkels

Yes, I still have the problem with same error message.

louisbrulenaudet avatar Oct 28 '23 09:10 louisbrulenaudet

ecosystem.config.cjs :

module.exports = {
  apps : [{
    name   : "dev",
    script : "./express.js",
    watch  : "true",
  },{
    name   : "blue",
    script : "./express.js",
    watch  : "true",
  },{
    name   : "black",
    script : "./express.js",
    watch  : "true",
  }]
}

and run pm2 start ecosystem.config.cjs

ssv1907 avatar Nov 06 '23 20:11 ssv1907

Are you running the latest pm2 version? I just tried to reproduce this with node v20.11.1 and the exact code from your first post and for me it works fine!

module.exports = {
  apps: [{
    script: 'app.js',
    watch: '.'
  }]
};

Started with: pm2 start ecosystem.config.js

ultimate-tester avatar Feb 29 '24 15:02 ultimate-tester