【发布时间】:2021-08-16 23:09:10
【问题描述】:
假设我有以下目录结构:
- functions
- functionOne
- tsconfig.json
- index.ts
- package.json
- node_modules
- layers
- layerOne
- tsonfig.json
- index.ts
- index.js (compiled index.ts)
- package.json
- node_modules
在functions/functionOne/index.ts 内,我正在尝试导入layerOne:
import JenkinsCredentials from '@prefix/module-name';
现在,我知道 TypeScript 会像“@prefix/module-name 到底是什么。所以,在 tsconfig.json 中我写了以下内容:
"baseUrl": ".",
"paths": {
"@prefix/module-name": ["../../layers/layerOne"]
}
但是,这似乎不起作用。我收到以下错误:
Cannot find module '@prefix/module-name' or its corresponding type declarations.ts(2307)
我认为设置 baseURL 和 paths 会对此有所帮助吗?我在做什么错/我需要做什么才能让 TypeScript 将 @prefix/module-name 的自定义模块名称映射到目录 "../../layers/layerOne"
注意:自定义名称的原因是 Lambda 层以这种方式引用。
【问题讨论】:
标签: javascript node.js typescript amazon-web-services aws-lambda