Next.js Discord

Discord Forum

how to use PM2 ecosystem.config in nextjs with custom .env

Unanswered
Singapura posted this in #help-forum
Open in Discord
SingapuraOP
Hello,

I am using Nextjs v16.0.3 Page Router, and I am planning to have ecosystem.config.js|cjs for PM2 on Ubuntu Linux VPS Server, but I've 2 custom script & .env for the Testing purpose:

"scripts": {
    "dev": "next dev",
    "dev:qa": "dotenv -e .env.qa next dev",
    "dev:uat": "dotenv -e .env.uat next dev",
    "build": "next build",
    "build:qa": "dotenv -e .env.qa next build",
    "build:uat": "dotenv -e .env.uat next build",
    "start": "next start",
    "start:qa": "dotenv -e .env.qa next start",
    "start:uat": "dotenv -e .env.uat next start",
    "sass": "node-sass --watch public/assets/sass/main.scss public/assets/css/main.css --source-map public/assets/css/main.css.map",
    "lint": "next lint"
  },


as I am using dotenv -e .env.qa to build the Nextjs App and use .env.qa for this build, so I need help & guidance from the community who had used PM2 ecosystem.config for their Nextjs Project.

0 Replies