var port = process.env.API_PORT; if (!port) { port = 8888; } code example Example: const port = process.env.port || 3000 const port = process.env.port || 3000