Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 Library - Could not resolve entry

I am getting the following error while building the angularlibrary project.

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

I only get this error when I add new module in public_api.ts file

export * from './lib/designer.service';
export * from './lib/designer.component';
export * from './lib/designer.module';
export * from './lib/core/app-core.module'; // new module

I am using the following command to build the module

ng build lib

Any idea why I am getting this error?

like image 435
Abhishek Avatar asked Feb 27 '19 06:02

Abhishek


Video Answer


2 Answers

I was facing the same issue. My mistake was:

In one of my service in the library, I used environment variable and imported it like this:

import { environment } from 'src/environments/environment';

So while building, it couldn't get the relative path and was showing the error. I removed it and it worked fine.

Please ensure that in your library module, you are not referencing any main project related item or not importing any relative path

like image 188
Adrita Sharma Avatar answered Nov 15 '22 12:11

Adrita Sharma


I had the same issue with my component library project. I was using library A into library B by referring that A library from the dist folder. The issue was because of referring library A by path.

I solved this issue by properly installing library A into B using npm install [email protected].

This solved my problem.

like image 26
Brijesh Wani Avatar answered Nov 15 '22 10:11

Brijesh Wani