Cannot use variable with pm2

HiI am trying to use this code below in ecosystem.config.js via pm2 but it is not working. i can use up to N8N_BASIC_AUTH_PASSWORD correctly, but not anything beyond that.

code used

module.exports = {
    apps : [{
        name   : "n8n",
        env: {
            N8N_BASIC_AUTH_ACTIVE:true,
            N8N_BASIC_AUTH_USER:"user",
            N8N_BASIC_AUTH_PASSWORD:"pass"
            N8N_HOST=subdomain.domain.com
            WEBHOOK_URL=https://subdomain.domain.com
            GENERIC_TIMEZONE=Europe/London
            EXECUTIONS_TIMEOUT=3600
            EXECUTIONS_TIMEOUT_MAX=7200
        }
    }]
}

the error shows

[PM2][ERROR] File /root/ecosystem.config.js malformated
/root/ecosystem.config.js:8
            N8N_HOST=subdomain.domain.com
            ^^^^^^^^

please help

Hey @bari86,

Looks like the first few have " " around it, have you tried adding those around the others?

1 Like

Looks like there are also a few commas missing. For example N8N_BASIC_AUTH_USER:"user", ends with one, but the next line doesn’t. Check out PM2 - Environment Variables (keymetrics.io) for an example ecosystem file.

Sorry. I did miss the commas. Added commas to all line now except the last line. Now I put and it shows this error. i tried with " " and without.

 N8N_HOST=sub.domain.com,
            ^^^^^^^^^^^^^^^^^^^^^^

I think its working now. I made few other error like : with =

module.exports = {
    apps : [{
        name   : "n8n",
        env: {
            N8N_BASIC_AUTH_ACTIVE:true,
            N8N_BASIC_AUTH_USER:"user",
            N8N_BASIC_AUTH_PASSWORD:"password",
            N8N_HOST:"sub.domain.com",
            WEBHOOK_URL:"https://sub.domain.com",
            GENERIC_TIMEZONE:"Europe/London",
            EXECUTIONS_TIMEOUT:3600,
            EXECUTIONS_TIMEOUT_MAX:7200
        }
    }]
}

2 Likes

Great news and thanks for sharing your working config!