Open Gharsnull opened 2 years ago
I was getting the same issue trying to run pm2 with docker-compose. I tried this and it worked for me npm version - 10.2.5 node version - 20.10.0 docker-compose version - 1.29.2 pm2 version - 5.3.0
ERROR
/usr/bin/docker-compose:2
# EASY-INSTALL-ENTRY-SCRIPT: 'docker-compose==1.29.2','console_scripts','docker-compose'
^
SyntaxError: Invalid or unexpected token
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
before:
module.exports = {
apps: [
{
name: '<process-name>',
cwd: '/var/www/<project>', // must have absolute path
script: 'docker-compose',
args: 'up -d',
env: {
NODE_ENV: 'development',
},
},
],
};
after:
module.exports = {
apps: [
{
name: '<process-name>',
cwd: '/var/www/<project>', // must have absolute path
script: '/usr/bin/docker-compose',
args: ['up', '-d'], //arguments in array instead of string and absolute path of docker-compose
env: {
NODE_ENV: 'development',
},
},
],
};
Hope this helps you or anyone else having this issue :)
What's going wrong?
I'm trying to start a service using docker-compose up, but pm2 is not able to execute docker-compose file. docker-compose up command runs fine if I execute it manually, it just fails when pm2 executes it
Supporting information