Javascript TypeScript-从自定义位置导入模块(非相对)

Javascript TypeScript-从自定义位置导入模块(非相对),javascript,node.js,typescript,amazon-web-services,aws-lambda,Javascript,Node.js,Typescript,Amazon Web Services,Aws Lambda,假设我有以下目录结构: - functions - functionOne - tsconfig.json - index.ts - package.json - node_modules - layers - layerOne - tsonfig.json - index.ts - index.js (compiled index.ts) - package.json - n

假设我有以下目录结构:

- 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

从'@prefix/module name'导入凭据;
现在,我知道TypeScript将类似于“前缀/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
路径会有帮助吗?我做错了什么/我需要做什么才能让TypeScript将
@prefix/module name
的自定义模块名映射到目录
。/../layers/layerOne“


注意:自定义名称的原因是以这种方式引用Lambda层。

路径
关键字将
视为
tsconfig.json
文件的路径

您需要将
路径设置为:

“baseUrl”:“,
“路径”:{
“@prefix/module name”:[“/layers/layerOne”]
}

因此,从“@prefix/module name”调用
import-JenkinsCredentials;
从何处调用并不重要,它将始终生成相同的文件。

我将路径设置为
/layers/layerOne
,但是,我仍然收到相同的错误。我重新启动了VS-code,但仍然收到相同的错误消息。因此,实际问题是我当时遇到了它我的
tsconfig.json的根目录
,不在
编译器选项
下。很抱歉出现这些问题