How do I effectively npm link when using bit.dev?

1k Views Asked by At

I have two git repos;

  • one is a component library, containing multiple components which are all individually exported to bit.dev
  • two is a next/react app that uses the components from the library

My folders are roughly;

component-library
 |- .bitmap
 |- /src
   |- /button
      |- /button.js
   |- /header
      |- /header.js

next-react-project
 |- /src
   |- /pages
      |- /home.js

I want to be able to see local changes to my components in my react app without having to first tag and export them to bit. Before using bit.dev, i'd do this by running something like npm link ../component-library.

How can I achieve this with bit.dev?

1

There are 1 best solutions below

0
On

Since bit harmony, bit added a --target flag to the bit link command. The usage is:

bit link --target <path to the destination>

If you want to use it the same way you use npm link and link your packages globally, you can run this command in your workspace:

bit link --target $(dirname "$(npm root -g)")

Then inside the project (your next/react app) where you want to install the package:

npm link <packageName>