How to Deploy a NextJS Application in Production with PM2?
NextJS is a JavaScript Framework. It lets you build a server-side rendering and static web application using React. In this article, I will explain how to deploy a NextJS application in Production with PM2 in just 3 steps.
Step 1. Open the package.json file and update scripts with the below code
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
}
Step 2. Create a production build using the below script
npm run build
Step 3. Once build completed successfully, execute below commands to run NextJS application with PM2
pm2 start npm --name "my_app_name" -- start
No comments:
Post a Comment