pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

Use tsx instead of ts-node for ts runtime

Open antoine-lin opened this issue 3 years ago • 2 comments

Hi, ts-node should not be used to run a ts server due to poor runtime performances caused by the compilation. Could it be possible to consider using tsx instead?

Related issue : #3199

antoine-lin avatar Dec 01 '22 10:12 antoine-lin

For anyone visiting this issue, pass tsx as a loader to node using interpreterArgs

module.exports = {
  apps: [
    {
      name: 'server',
      script: './server/index.ts',
      interpreter: 'node',
      interpreterArgs: '--loader tsx',
    },
  ],
};

vramana avatar Feb 04 '23 13:02 vramana

For anyone using this from node v18 on --loader is deprecated so the new flag to be passed is --import:

module.exports = {
  apps: [
    {
      name: 'server',
      script: './server/index.ts',
      interpreter: 'node',
      interpreterArgs: '--import tsx',
    },
  ],
};

See https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#esm-and-customization-hook-changes for reference.

ZeldOcarina avatar Jan 18 '24 09:01 ZeldOcarina