Skip to content

Share components between packages? #1405

Answered by aaronadamsCA
aaronadamsCA asked this question in Q&A
Discussion options

You must be logged in to vote

Naturally, after struggling for an hour or two and writing this up, I now have a good idea of where the problem lies:

  • Putting react in devDependencies means react-components/node_modules/react/ exists
  • Lerna symlinks react-components/ into each Gatsby app's node_modules/
  • This means components will variously use node_modules/react/ or node_modules/react-components/node_modules/react/, causing the error
  • This is just an unfortunate limitation of Lerna: lerna/lerna#2605

I thought I could work around this by moving react from the component library devDependencies to the root package devDependencies, but this didn't actually seem to work!

What did seem to work is to add this to my gatsby-node.js

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
3 replies
@atanasster
Comment options

@aaronadamsCA
Comment options

@atanasster
Comment options

Answer selected by lachlanjc
Comment options

You must be logged in to vote
1 reply
@aaronadamsCA
Comment options

Comment options

You must be logged in to vote
3 replies
@Stvad
Comment options

@aaronadamsCA
Comment options

@cmavelis
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants