修改next app的默认端口

StoneHoo Lv4

When you are running your next.js application locally, default port is 3000. Since it is a commonly used port, you might have other service running on the same port.

You can set port number using below ways:

  1. package.json
    In the scripts section of package.json, there will be a command for dev.

Usually it will be “dev”: “next”.

To set the port number, modify the package.json contents as below to make the port number to 3005 or any other number of your choice.

“dev”: “next dev -p 3005”

  1. specify port number in run command
    While running your application, specify the port number. You can use the command like below:

npm run dev – -p 3005

  • Title: 修改next app的默认端口
  • Author: StoneHoo
  • Created at : 2023-05-12 22:20:58
  • Updated at : 2024-01-21 01:41:15
  • Link: https://www.ozak.ca/2023/05/12/修改next-app的默认端口/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
修改next app的默认端口