Angular 6 库 - 无法解析条目
Angular 6 Library - Could not resolve entry
我在构建 angular
库项目时遇到以下错误。
Building Angular Package
Building entry point '@abc/lib'
Compiling TypeScript sources through ngc
Bundling to FESM2015
BUILD ERROR
Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
Error: Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
at error (C:\Dev\abc\node_modules\rollup\dist\rollup.js:3460:30)
at C:\Dev\AppBuilder\node_modules\rollup\dist\rollup.js:21474:17
Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
Error: Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
at error (C:\Dev\abc\node_modules\rollup\dist\rollup.js:3460:30)
at C:\Dev\AppBuilder\node_modules\rollup\dist\rollup.js:21474:17
只有在 public_api.ts
文件
中添加新的 module
时才会出现此错误
export * from './lib/designer.service';
export * from './lib/designer.component';
export * from './lib/designer.module';
export * from './lib/core/app-core.module'; // new module
我正在使用以下命令构建模块
ng build lib
知道我为什么会收到此错误吗?
我遇到了同样的问题。我的错误是:
在图书馆的一项服务中,我使用了环境变量并像这样导入它:
import { environment } from 'src/environments/environment';
因此在构建时,它无法获取相对路径并显示错误。我删除了它,它工作正常。
请确保在您的库模块中,您未引用任何与主项目相关的项目或未导入任何相对路径
我的组件库项目也遇到了同样的问题。
我通过从 dist 文件夹中引用 A 库,将库 A 用于库 B。
问题是因为通过路径引用库 A。
我通过使用正确地将库 A 安装到 B 中解决了这个问题
npm 安装 A@0.0.1.
这解决了我的问题。
我在构建 angular
库项目时遇到以下错误。
Building Angular Package
Building entry point '@abc/lib'
Compiling TypeScript sources through ngc
Bundling to FESM2015
BUILD ERROR
Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
Error: Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
at error (C:\Dev\abc\node_modules\rollup\dist\rollup.js:3460:30)
at C:\Dev\AppBuilder\node_modules\rollup\dist\rollup.js:21474:17
Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
Error: Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
at error (C:\Dev\abc\node_modules\rollup\dist\rollup.js:3460:30)
at C:\Dev\AppBuilder\node_modules\rollup\dist\rollup.js:21474:17
只有在 public_api.ts
文件
module
时才会出现此错误
export * from './lib/designer.service';
export * from './lib/designer.component';
export * from './lib/designer.module';
export * from './lib/core/app-core.module'; // new module
我正在使用以下命令构建模块
ng build lib
知道我为什么会收到此错误吗?
我遇到了同样的问题。我的错误是:
在图书馆的一项服务中,我使用了环境变量并像这样导入它:
import { environment } from 'src/environments/environment';
因此在构建时,它无法获取相对路径并显示错误。我删除了它,它工作正常。
请确保在您的库模块中,您未引用任何与主项目相关的项目或未导入任何相对路径
我的组件库项目也遇到了同样的问题。 我通过从 dist 文件夹中引用 A 库,将库 A 用于库 B。 问题是因为通过路径引用库 A。
我通过使用正确地将库 A 安装到 B 中解决了这个问题 npm 安装 A@0.0.1.
这解决了我的问题。