Exporting a node module with a component library in Angular?

789 views Asked by At

I made a component library using the Angular CLI and I have have a separate test application that imports this library.

The component library builds nicely, but I am having trouble running "ng serve" in the test application because one of the components in the library uses an npm package I specifically installed in the library: 'jwt-decode".

For instance one component in the library has the line:

import * as jwt_ from 'jwt-decode';

And the library's package.json has the lines

"dependencies": {
    "@types/jwt-decode": "^2.2.1",
    "jwt-decode": "^2.2.0"
 }

While the component library builds correctly, when I ng-serve the application that imports this library, I get the error:

Module not found: Error: Can't resolve 'jwt-decode' in '.../dist/myLibrary/fesm2015'.

Basically, how do I export a package(that I npm installed in the library), with the component library itself. Do I need to add anything to the library's public-api.ts file?

0

There are 0 answers