英文:
Problems with nodejs typescript - tsconfig file
问题
TSError: ⨯ 无法编译TypeScript:
错误 TS5023:未知的编译器选项'allowImportingTsExtensions'。
at createTSError (/home/minh/Documents/Detech/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/home/minh/Documents/Detech/node_modules/ts-node/src/index.ts:863:19)
at createFromPreloadedConfig (/home/minh/Documents/Detech/node_modules/ts-node/src/index.ts:874:36)
at phase4 (/home/minh/Documents/Detech/node_modules/ts-node/src/bin.ts:543:44)
at bootstrap (/home/minh/Documents/Detech/node_modules/ts-node/src/bin.ts:95:10)
at Object.<anonymous> (/home/minh/Documents/Detech/node_modules/ts-node/src/child/child-entrypoint.ts:24:10)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12) {
diagnosticCodes: [ 5023 ]
}
英文:
TSError: ⨯ Unable to compile TypeScript:
error TS5023: Unknown compiler option 'allowImportingTsExtensions'.
at createTSError (/home/minh/Documents/Detech/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/home/minh/Documents/Detech/node_modules/ts-node/src/index.ts:863:19)
at createFromPreloadedConfig (/home/minh/Documents/Detech/node_modules/ts-node/src/index.ts:874:36)
at phase4 (/home/minh/Documents/Detech/node_modules/ts-node/src/bin.ts:543:44)
at bootstrap (/home/minh/Documents/Detech/node_modules/ts-node/src/bin.ts:95:10)
at Object.<anonymous> (/home/minh/Documents/Detech/node_modules/ts-node/src/child/child-entrypoint.ts:24:10)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12) {
diagnosticCodes: [ 5023 ]
}
This is the error when I put allowImportingTsExtensions: true
to tsconfig
file before run server.
If I do not put that line to tsconfig
in, all other files I import with *.ts
throw an error in VSCode. The server can run normally though.
Below is the error in VSCode when I don't use allowImportingTsExtensions
> An import path can only end with a .ts
extension when allowImportingTsExtensions
is enabled.
If I put it in the error in VSCode is clear but the server is crash.
If I do not, The VSCode throws an error but the server still running.
Versions:
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
tsconfig
file:
{
"compilerOptions": {
// "allowImportingTsExtensions": true,
"rootDir": "./src",
"outDir": "./dist",
"baseUrl": "./src",
"paths": {
"@app/*": ["./*"],
"@common/*": ["common/*"],
},
"plugins": [
{ "transform": "typescript-transform-paths" }
],
"target": "es5",
"module": "ESNext",
"lib": ["es6"],
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"incremental": true,
"declaration": true,
"noEmit": true,
"jsx": "react"
},
"ts-node": {
"esm": true,
"transpileOnly": true,
"swc": true,
"require": [
"typescript-transform-paths/register",
"tsconfig-paths/register"
],
},
"include": ["src/**/*.ts","./","src/*.ts"],
"exclude": ["node_modules"],
}
答案1
得分: 2
我只是通过将TypeScript更新到版本5来解决了这个问题。谢谢大家。
英文:
I just solve the problem by update typescript to version 5. Thanks all
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论