如何使用 nx 工作区在 PM2 中部署 NestJs 应用程序 - AWS ec2

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

我正在使用 NX 工作区。在我的项目中有一个 Nest Js 应用程序。我曾经在AWS EC2中部署这个应用程序。我在那里安装了PM2。

// pm2.config.js
module.exports = {
  apps: [
    {
      name: 'Backend API',
      script: 'npm',
      args: 'start',
      cwd: 'apps/api/src',
      interpreter: 'ts-node',
      env: {
        PORT: 3000,
        NODE_ENV: 'production',
      },
    },
  ],
};


该条位于我的根目录中,我运行 pm2 start pm2.config.js

不工作。有什么解决办法吗

nestjs pm2 nx-workspace
1个回答
0
投票
// pm2.config.js
module.exports = {
  apps: [
    {
      name: 'Backend API',
      script: 'npx',
      args: 'nx run api:serve',
      cwd: 'apps/api',
      interpreter: 'ts-node',
      env: {
        PORT: 3000,
        NODE_ENV: 'production',
      },
    },
  ],
};

我只是把这个脚本改成这样。工作了

© www.soinside.com 2019 - 2024. All rights reserved.