Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems env-cmd not working with pm2 #315

Open
ujjavaljani opened this issue Jul 12, 2021 · 2 comments
Open

It seems env-cmd not working with pm2 #315

ujjavaljani opened this issue Jul 12, 2021 · 2 comments
Labels

Comments

@ujjavaljani
Copy link

Hello,
I am using env-cmd in my typescript application.
for production I am creating node js build using tsc and after build when I tried to pass custom env file then it throws error like .env file could not found.

image

I am trying to run command npm run pm2:start:qa.

Thanks in advance.

@erassynathingo
Copy link

Perhaps this could help. Create an pm2.config.js file, define your configs in there and access the ENV variables as show below.

module.exports = {
    apps: [
        {
            name: "app-namne",
            script: "./build/index.js",
            watch: true,
            ignore_watch: [
                ".git",
                ".md",
            ],
            time: true,
            env: {
                PORT: process.env.PORT,
            },
        },
    ],
};

qa start script should look something like this:

npm run build && env-cmd -f ./environments/.env pm2 start pm2.config.js",

@k-yle k-yle added the question label Dec 10, 2024
@k-yle
Copy link
Collaborator

k-yle commented Dec 10, 2024

Hi, could you please provide a minimal reproducible example for this issue?

this screenshot isn't enough information to help debug this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants