DEV Community

Discussion on: How to Create and Publish a React Component Library

Collapse
 
iankm profile image
Roomak • Edited

Hey alex! Thank you so much for such a clear summary of the component library creation process. I followed your advice but can't seem to test this with a local project.

My component library is housed in the local directory "component-library". I used npm link ../component-library in my project. When I try to important Button from my component library, I get:

Error: Can't resolve './Button' in 'component-library/dist/esm/types/components'

Any advice on this? I've double checked my file structure versus yours at least 20 times.

Collapse
 
keentdev profile image
Keanu Kent B. Gargar

Once you used "npm link" on your component library, also make sure to include that linked npm on your main app by using "npm link NAME_OF_YOUR_COMPONENT_PACKAGE", name is indicated on your component library' package.json name.

Some comments have been hidden by the post's author - find out more