node.jsangularnpmangular6npmjs

Publish Angular 6 library to npmjs with README.md


I'm developing a Angular 6 library which I want to publish to npmjs. The workspace (sample) and the library is versioned on GitHub. I've created the library by using the Angluar-CLI's command npm library lib-name.

The projects README.md is located in the root folder of the workspace project. As indicated in a guide on Medium, I've built the library and used the following commands to publish to npm:

ng build ng-as-multiselect-dropdown --prod
cd dist/ng-as-multiselect-dropdown
npm publish

The library is now published at npmjs, but npmjs can't pick up the README.md as the readme is not located in the libraries code, but in the workspace project:

"Unable to find a readme for @austrianstandards/ng-as-multiselect-dropdown@1.0.0"

How to publish the library and include the README.md in the build, so both the readme gets displayed on both GitHub and npmjs?


Solution

  • You have to create a readme under projects folder and then build it and then cd to dist directory of the lib and npm publish it

    This will solve your problem