校园网站建设标书百度公司官方网站
✅ 你现在想做的是:
用 PM2 运行 基于 tsx(或 ts-node 生态) 的 TypeScript 文件,不经过 tsc 编译,直接运行 .ts 文件 ✅
这在现代项目中非常流行,尤其使用 tsx 这个超快的 TypeScript 执行器,是 ts-node 的轻量替代方案,速度快、不需要预编译、支持 ESModule、自动识别扩展名,非常适合配合 PM2 使用。
npm install tsx -gpm2 start index.ts --interpreter tsx
✅ 3. 推荐使用 ecosystem.config.js
module.exports = {apps: [{name: "index",script: "index.js",interpreter: "tsx",watch: false}]
}