Discussion: Best way to create npm packages with create-react-app
See original GitHub issueHello! Love this tool, however, I’m using it to create a component library that I want to publish on NPM and am running into issues accessing the components after I’ve installed my package.
Process:
npm run build
npm publish
Locally, if I get them from the main file, it works fine (as expected)
Main.js
export { default as Button } from './modules/Button';
export { default as Navicon } from './modules/Navicon';
...
App.js
import {
Button,
Navicon
} from '../lib/Main';
But, after I install the package and import the components as shown above from package-name
they are always undefined
.
Thoughts into the best practice for this?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:16
- Comments:15 (3 by maintainers)
Top Results From Across the Web
How to create an npm library from react components
First we shall initialize a react project. So got to your terminal and enter the directory that you want to create your project...
Read more >Create a New React App
Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in...
Read more >Best way to create npm packages with create-react-app
Best way to create npm packages with create-react-app. Init project create-react-app create-react-app-npm cd create-react-app-npm
Read more >Using create-react-app - LearnHowToProgram.com
This involves creating custom webpack configurations, adding Node packages, and customizing Babel to fit the needs of the project. While this is ...
Read more >Deployment | Create React App
npm run build creates a build directory with a production build of your app. Set up your favorite HTTP server so that a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
HI, i’ve customised
create-react-app
to create React NPM library. Also i’m constantly updating repository with the updates of create-react-app, so we have all new features and bug fixes of it.https://github.com/DimiMikadze/create-react-library
https://medium.com/@lokhmakov/best-way-to-create-npm-packages-with-create-react-app-b24dd449c354