pm2 无法在 VITE 上运行构建

问题描述 投票:0回答:1

我尝试在Vite上构建项目(npm run build) 并在端口 3003 上运行它(npx 运行预览),因为其他端口很忙

但是 pm2 不断更新我的构建

可能是什么问题?之前我只收集了Next项目,一切都很好,但是Vite遇到了一些困难

vite.confing.ts

    import { defineConfig } from 'vite'
    import react from '@vitejs/plugin-react-swc'

    export default defineConfig({
      plugins: [react()],
    })

尝试过:

git clone 'project_name'
npm i
npm run build
pm2 start npx --name 'name' -- preview

pm2状态:

reactjs vite pm2
1个回答
0
投票

您尝试过使用ecosystem.config.js吗

module.exports = {
  apps: [
    {
      name: `vite-app`,
      script: "serve",
      env: {
        PM2_SERVE_PATH: "./dist",
        PM2_SERVE_PORT: 5173,
        PM2_SERVE_SPA: "true",
        NODE_ENV: 'production',
      },
    },
  ],
};

然后 npm run build

"build": "tsc && vite build && pm2 start ecosystem.config.js --env production"
© www.soinside.com 2019 - 2024. All rights reserved.