pm2
pm2 copied to clipboard
Use tsx instead of ts-node for ts runtime
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
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',
},
],
};
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.