【发布时间】:2019-07-23 22:21:37
【问题描述】:
我正在尝试使用jasmine-ts,但总是出现找不到模块的错误,所以我决定使用tsc检查一下,找出问题所在,我的文件夹结构如下:
\src\app\...
\src\tests\...
所以我在“tests”文件夹级别创建了tsconfig.json,如下所示
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "../",
"paths": {
"@app/*": [
"app/*"
]
}
}
}
在我的*.test.ts 文件中,我在应用程序目录中导入了一个模块,但仍然收到模块未找到错误。
找不到模块'@app/core/data/my-module
我尝试了以下命令
tsc --traceResolution test1.test.ts
它给了我
test1.test.ts:2:23 - error TS2307: Cannot find module '@app/core/data/my-module'.
2 import { Field } from '@app/core/data/my-module'
~~~~~~~~~~~~~~~~~~~~~~~~~~
【问题讨论】:
-
当您运行
tsc --traceResolution test1.test.ts时,您并未使用tsconfig.json文件。而是运行tsc --traceResolution -p .或只运行tsc --traceResolution,如果需要,使用tsconfig.json中的files、include和exclude选项来限制处理的文件。如果这不能让你到达你想去的地方,请更新问题。
标签: angular typescript jasmine