Implement .env support for PORT property

This commit is contained in:
stretch07
2024-03-12 22:42:13 -07:00
parent e030321da0
commit 06fc54b18e
5 changed files with 24 additions and 4 deletions
+3 -1
View File
@@ -2,9 +2,11 @@ const express = require("express");
const { generateDevHtml, build } = require("./utils.js");
const { argv } = require('node:process');
const chalk = require('chalk');
const dotenv = require('dotenv');
dotenv.config();
const app = express();
let port = 4000; // Starting port
let port = process.env.PORT ?? 4000; // Starting port
const maxAttempts = 10; // Maximum number of ports to try
const env = argv[2] ?? "dev";