pm2
pm2 copied to clipboard
File ecosystem.config.js malformated
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.
I use Node 20.6.0 with Yarn berry.
Did you try renaming the file to .cjs? ecosystem.config.cjs
Yes, I still have the problem with same error message.
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
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