You are viewing a single comment's thread from:

RE: Nuxt开发指南

in #starnote2 days ago
//开发环境
//package.json
"dev": "nuxt dev --port 3200"
// 或是这样:
"config": {  // here are the changes
    "nuxt": {
        "host": "0.0.0.0",
        "port": "3333"
    }
}
//或者在 nuxt.config.ts 中设置 只在开发中有效
devServer: {
  port: 9685
}
//或者,在 .env 中设置 `PORT = 9685` 即可!  
这样访问:
 if(process.server){
  console.log(566, process.env.PORT)
 } 

//设置服务器端口 port, 找到源码,直接修改即可!
源码: .output/server/index.mjs
//const port = destr(process.env.NITRO_PORT || process.env.PORT) || 3e3;
const port = 5896