我想在 pm2 中启动 typescript ESM
我配置ESM模块:
我尝试使用 pm2 启动一个简单的程序 main.ts:
import { msg } from './lib/helper.js';
msg('Hello world!');
并收到此错误:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /var/node/srv2/src/main.ts
标准命令工作正常:
ts-node src/main.ts
我尝试使用 ecosystem.config.cjs - 但它也不起作用。
我把完整的例子放到github上: https://github.com/gayratv/pm2-typesript-esm
有什么方法可以使用 pm2 启动 typescript ESM 吗?