1?node_modules/@types/express/index.d.ts:128:1
? ? 128 export = e;
? ? ? ? ~~~~~~~~~~~
? ? This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
解决办法:
"compilerOptions": {
"esModuleInterop":true
}
2??TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
"scripts": {
"dev": "vite",
"service":"nodemon service.ts",
}
这里通过nodemon运行service.ts报错。
解决办法:去掉pack.json中的type:module
{
"name": "tsv3",
"private": true,
// "type": "module", //去掉
"scripts": {
"dev": "vite",
"service":"nodemon service.ts",
}
二:TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
解决办法:(注意:"ts-node"选项和complierOptions同级)
{
"compilerOptions": {
"module": "ESNext" // or ES2015, ES2020
},
"ts-node": {
// Tell ts-node CLI to install the --loader automatically, explained below
"esm": true
}
}