next版本:13.5.4
一、修改端口
在package.json文件当中修改启动命令
"scripts": {
"dev": "next dev -p 3100",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
这样以来就会以端口3100进行启动。
二、开发启动自动开发浏览器
还是在package.json文件当中修改启动命令,并添加启动打开的地址
"scripts": {
"dev": "pnpm open-browser && next dev -p 3100",
"open-browser": "start http://localhost:3100",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
我的管理依赖用的是pnpm,如果你用的是npm,那么将是:
"scripts": {
"dev": "npm run open-browser && next dev -p 3100",
"open-browser": "start http://localhost:3100",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
以上就是nextjs 项目改端口,以及开发启动自动打开浏览器的配置。好了,开启你的炫酷旅程吧!