简体   繁体   English

Angular 使用私人图书馆

[英]Angular use private library

I developed a library that I then published on a repo so that I could use it in other projects via a npm我开发了一个库,然后将其发布在 repo 上,以便我可以通过 npm 在其他项目中使用它

Except that when I launch my project I have the following error :除了当我启动我的项目时出现以下错误:

ERROR in Cannot resolve type entity i3.FontAwesomeModule to symbol

My library has the following dependencies:我的库具有以下依赖项:

import * as i0 from "@angular/core";
import * as i1 from "./myComponentInLib.component";
import * as i2 from "@angular/common";
import * as i3 from "@fortawesome/angular-fontawesome";
import * as i4 from "@angular/router";
import * as i5 from "angular-svg-icon";

My project in which I install the library contains some dependencies that are in the lib but not all.我安装库的项目包含一些在库中但不是全部的依赖项。 Do I have to install the other dependencies manually?我是否必须手动安装其他依赖项?

Yes!是的! you have to install peer dependencies manually in the project you are utilizing the library component.您必须在使用库组件的项目中手动安装对等依赖项。

It is mentioned in the angular documentation : https://angular.io/guide/creating-libraries#use-typescript-path-mapping-for-peer-dependencies它在角度文档中提到: https : //angular.io/guide/creating-libraries#use-typescript-path-mapping-for-peer-dependencies

While developing a library, you must install all peer dependencies through devDependencies to ensure that the library compiles properly.在开发库时,必须通过 devDependencies 安装所有对等依赖项,以确保库正确编译。 A linked library will then have its own set of Angular libraries that it uses for building, located in its node_modules folder.然后,链接库将拥有自己的一组用于构建的 Angular 库,位于其 node_modules 文件夹中。 However, this can cause problems while building or running your application.但是,这可能会在构建或运行应用程序时导致问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM