package.json
{
"dependencies": {
"@types/node": "^22.14.0",
"axios": "^1.8.4",
"node-fetch": "^3.3.2",
"nodemailer": "^6.9.16",
"ts-node": "^10.9.2"
},
"type": "module",
"devDependencies": {
"@types/axios": "^0.14.4",
"typescript": "^5.8.2"
}
}
tsconfig.json
{
"compilerOptions": {
/* 基础配置 */
"target": "ES2022", // 使用现代 ES 标准(匹配 Node.js 18+)
"module": "NodeNext", // 使用 Node.js 的模块解析方式
"moduleResolution": "NodeNext", // 明确指定 Node 模块解析策略
/* 类型检查增强 */
"strict": true, // 开启所有严格类型检查
"noImplicitAny": true, // 禁止隐式 any 类型
"strictNullChecks": true, // 严格的 null/undefined 检查
"strictBindCallApply": true, // 严格检查 bind/call/apply
"strictFunctionTypes": true, // 严格函数类型检查
/* 模块处理 */
"esModuleInterop": true, // 改进 CommonJS/ESM 互操作性
"resolveJsonModule": true, // 允许导入 JSON 文件
"allowSyntheticDefaultImports": true, // 允许 CJS 模块的默认导入
/* 源码映射 */
"sourceMap": true, // 生成 sourcemap
"inlineSources": true, // 将源码嵌入 sourcemap
/* 实验性特性 */
"experimentalDecorators": true, // 启用装饰器(如需使用装饰器)
"emitDecoratorMetadata": true, // 生成装饰器元数据
/* 路径别名 */
"baseUrl": ".", // 基准路径
"paths": {
"@/*": ["src/*"] // 路径映射配置
}
},
//不可或缺,少了会报错无法识别.ts文件
"ts-node": {
// Tell ts-node CLI to install the --loader automatically, explained below
"esm": true
}
}