我将从相对路径导入切换到我的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": ".",两者都不起作用。
发布于 2022-10-13 17:01:18
对于windows /不起作用。你可以用"sh ./.“或者使用反斜杠\
https://stackoverflow.com/questions/72156462
复制相似问题