【发布时间】:2023-01-09 05:59:49
【问题描述】:
我正在为我的 CDK 包从相对路径导入切换到绝对路径导入,并在运行 cdk synth 时出现此错误:
$ cdk synth
Error: Cannot find module 'lib/CodePipelineStack'
我按照这个using absolute paths in typescript for imports 在tsconfig.json 文件中设置了baseUrl 和paths。
不知道为什么它不工作。
更多上下文
我的项目结构如下所示:
我的 tsconfig.json 是:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"bin/*": [ "./bin/*" ],
"lib/*": [ "./lib/*" ],
"test/*": [ "./test/*" ]
},
"target": "ES2018",
"module": "commonjs",
"lib": [
"es2018"
],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types"
]
},
"exclude": [
"node_modules",
"cdk.out"
]
}
我试过 "baseUrl": "./" 和 "baseUrl": ".",都不起作用。
【问题讨论】:
标签: typescript aws-cdk