kor*_*inp 4 import typescript tsconfig angular-cli angular
该项目是通过有角度的CLI生成的。我具有以下文件夹结构:
我想定义的路径栏文件夹tsconfig.app.json和进口Car到Garage。
我的tsconfig.app.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
...
"baseUrl": "./",
"paths" : {
"@bar" : ["foo/bar"]
},
...
},
...
}
Run Code Online (Sandbox Code Playgroud)
我的Garage.ts:
import { Car } from "@bar/Car";
export class Garage {}
Run Code Online (Sandbox Code Playgroud)
在garage.ts中,我有一个错误:
找不到模块“ @ bar / car”。
您需要这样定义paths:
"paths" : {
"@bar/*" : [
"foo/bar/*"
]
},
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请阅读
请不要忘记baseUrl在添加paths. 我花了几个小时试图找出我错在哪里。
"baseUrl": "./",
"paths": {
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9296 次 |
| 最近记录: |