javascriptreactjsnpmportnext.js

How to Set port in next.js


One application is running on port 3000 and I want to run another application on a different port from the default port, which is 3000. How do I change this in React Next.js? My package.json currently contains:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "next",
    "build": "next build",
    "start": "next start"
},

And the CLI command that I use to start dev is npm run dev.


Solution

  • This work for me:

    "scripts": { 
        "dev": "next dev -p 8080",
        "start": "next start -p 8080",
    },