我在nodejs中使用typescript,并且没有收到任何编译时错误,特别是在使用ES6模块语法时。
如果有任何帮助,这是我的
tsconfig.json
文件:
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["**/*.ts", "eslint.config.mjs"], // checks every ts/tsx file
"exclude": ["node_modules", "**/*.spec.ts"]
}
您的程序中有导入错误,似乎没有安装 Express 类型。
express 安装类型:
npm install @types/node @types/express --save-dev
然后再检查一下