【发布时间】:2021-11-01 08:07:52
【问题描述】:
我正在开发一个使用 node.js 和 typescript 的项目。如果我运行 TSC 或命令来构建项目,它可以工作,因为我的 tsconfig.json 中有 "experimentalDecorators": true 选项。
但是,当我使用具有相同配置的 pm2 将它放入我的开发服务器时,使用 exosystem.config.json 和不使用它都不起作用。
首先,我有这个 tsconfig.json:
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"skipLibCheck": true,
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"rootDir": "src",
"composite": true,
"declaration": true,
"noEmitOnError": false,
"preserveConstEnums": true,
},
"exclude": ["node_modules"],
"include": ["src"],
}
我的项目结构是:
- index.ts
- tsconfig.json
- src/
- ecosystem.config.js
我的生态系统.config.js 是:
module.exports = {
apps : [{
name: "app",
script: './index.ts',
autorestart: true,
exec_mode: "fork",
watch: true,
env: {
NODE_ENV: 'development',
},
env_production: {
NODE_ENV: 'production',
},
}
],
};
如果我调试 pm2 日志,我会遇到此错误:
【问题讨论】:
标签: node.js typescript pm2 tsconfig tsc