question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: Best way to create npm packages with create-react-app

See original GitHub issue

Hello! 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:closed
  • Created 7 years ago
  • Reactions:16
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

50reactions
DimiMikadzecommented, Mar 28, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found