Abhishek
Abhishek

Reputation: 701

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?

Upvotes: 7

Views: 10575

Answers (2)

Brijesh Wani
Brijesh Wani

Reputation: 61

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 A@0.0.1.

This solved my problem.

Upvotes: 2

Adrita Sharma
Adrita Sharma

Reputation: 22203

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

Upvotes: 25

Related Questions