关于 Angular 项目类型为 library 的工程使用 tsconfig.json 的问题

简介: 关于 Angular 项目类型为 library 的工程使用 tsconfig.json 的问题
+关注继续查看

我今天做 Angular 开发时,遇到一个很奇怪的问题:

在某个 Angular library 项目里,无法正确解析出 @Spartacus/core,image.pngimage.pngimage.png后来经过一番分析,发现是库文件夹里文件 tsconfig.json 引起的原因。

我把该文件的内容清空只剩下面一行,问题消失。

image.pngimage.pngimage.png目录中存在 tsconfig.json 文件表明该目录是 TypeScript 项目的根目录。 tsconfig.json 文件指定了编译项目所需的根文件和编译器选项。


https://stackoverflow.com/questions/52147201/angular-6-declare-path-for-library-in-tsconfig-lib-json


Angular will use the tsconfig.json file, which is configured in the angular.json file in architect --> build --> options --> tsconfig. Whereas VS Code uses the tsconfig.json file, which is at the bottom of the workspace. You need to add the paths in both configurations to get both of them to work correctly, or change the project to use the base tsconfig.json file in the angular.json file.


The tsconfig.json file has a property that extends which will take another file as base and override everything which are declared in the tsconfig.lib.json file. So if you have paths declared in the tsconfig.lib.json file, then the paths are no longer needed in the tsconfig.json file.

image.png

相关文章
|
2月前
|
API
什么是 Angular library 的 secondary entry points?
什么是 Angular library 的 secondary entry points?
48 0
|
2月前
|
JavaScript 编译器
Angular 应用 tsconfig.json 文件里的 typeRoots 属性讲解
Angular 应用 tsconfig.json 文件里的 typeRoots 属性讲解
16 0
|
2月前
|
JavaScript 前端开发
Angular tsconfig.json 文件里的 paths 用途
Angular tsconfig.json 文件里的 paths 用途
23 0
|
3月前
|
资源调度 JavaScript 前端开发
如何解决 Angular custom library module 在 ng build 时无法被识别的错误
如何解决 Angular custom library module 在 ng build 时无法被识别的错误
18 0
|
3月前
|
移动开发 前端开发 JavaScript
如何创建 Angular library 并在生产环境中消费
如何创建 Angular library 并在生产环境中消费
23 0
|
3月前
|
JavaScript 开发者
关于 Angular 应用 tsconfig.json 中的 target 属性
关于 Angular 应用 tsconfig.json 中的 target 属性
28 0
|
3月前
|
JavaScript 前端开发 API
关于 Angular 应用 tsconfig.json 中的 lib 属性
关于 Angular 应用 tsconfig.json 中的 lib 属性
92 0
|
8月前
|
API
什么是 Angular library 的 secondary entry points?
什么是 Angular library 的 secondary entry points?
|
8月前
|
JavaScript 编译器
Angular 应用 tsconfig.json 文件里的 typeRoots 属性讲解
Angular 应用 tsconfig.json 文件里的 typeRoots 属性讲解
|
JavaScript 前端开发 API
关于 Angular 应用 tsconfig.json 中的 lib 属性
关于 Angular 应用 tsconfig.json 中的 lib 属性
93 0
关于 Angular 应用 tsconfig.json 中的 lib 属性
推荐文章
更多