i have an ordinary next js application with the following scripts in my package.json file.
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start -p 3002"
},
I have a start script with the -p
tag to start the application on port 3002.
I hope to run this application using pm2
with the following script.
PORT=3002 NODE_PORT=3002 pm2 start npm --name "nextjs-website" -- start
Using the env variables PORT and NODE_PORT don't work. How do i start this application using the same port as mentioned in the package.json file.
Also is it possible to run the pm2 service the run the start
in the package.json file?