Issue
I have the simples example:
- I create Angular library inside workspace from official documentation:
ng new workspace-test --create-application=false
cd workspace-test
ng generate library lib-test
- Then I build library and I create npm link for it from ./dist/lib-test directory:
ng build lib-test
npm link
- Then I create simplest angular application:
ng new app-test
- Now I link my application to the library:
npm link lib-test
- When I try to use library inside my app, I get exception
Error: Module not found: Error: Can't resolve '../../../workspace-test/dist/lib-test/lib/lib-test.component' in 'C:\dev\app-test\src\app'
- My usage of the library in the app:
import { LibTestModule } from '../../../workspace-test/dest/lib-test'
...
imports: [
LibTestModule ,
I don't have idea what is going on, how to make it work? It basic example.
Solution
if you want to use local library in another local project then your library build should be inside project's node_modules folder
solution change the library build destination to the project's node_modules
assume you have the following folders
go to
my-lib>projects>my-lib>ng-package.jsonfilechange dest to
"../../../my-project/node_modules/my-lib"build your library
Answered By - Obada Saada

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.