[英]Nuxt3 Vite server port
我需要为 Nuxt3 配置服务器端口。 我尝试这样做:
nuxt.config.ts
import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig(
vite: {
server: {
port: 5000,
},
},
})
但它不起作用。 Nuxt3如何设置服务器端口?
我在所有平台(Windows、Linux、MacOS)中dev
和production
模式的解决方案:
cross-env
以支持跨平台。sudo npm i cross-env -g
package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev --port=8001",
"generate": "nuxt generate",
"preview": "cross-env PORT=8001 node .output/server/index.mjs"
},
"devDependencies": {
"nuxt": "3.0.0-rc.4"
},
}
yarn run preview
module.exports = {
apps: [
{
name: 'NuxtApp',
port: 3001,
exec_mode: 'cluster',
instances: '1',
script: './.output/server/index.mjs',
args: 'preview',
},
],
}
你可以在你的 ecosystem.config.js 中这样使用
如果您使用的是 PM2,请在生态系统.config.js 上设置端口
module.exports = {
apps: [
{
name: 'NuxtAppName',
exec_mode: 'cluster',
instances: 'max',
script: './.output/server/index.mjs',
port: 5000
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.