简体   繁体   English

使用 bit.dev 时如何有效链接 npm?

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

I have two git repos;我有两个 git 回购;

  • one is a component library, containing multiple components which are all individually exported to bit.dev一个是组件库,包含多个组件,这些组件都单独导出到 bit.dev
  • two is a next/react app that uses the components from the library二是使用库中组件的 next/react 应用程序

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.我希望能够在我的 React 应用程序中看到我的组件的本地更改,而不必首先标记并将它们导出到 bit。 Before using bit.dev, i'd do this by running something like npm link../component-library .在使用 bit.dev 之前,我会通过运行npm link../component-library类的东西来做到这一点。

How can I achieve this with bit.dev?我怎样才能用 bit.dev 做到这一点?

Since bit harmony, bit added a --target flag to the bit link command.自 bit harmony 以来,bit 在bit link命令中添加了一个--target标志。 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:如果你想像使用npm link一样使用它并全局链接你的包,你可以在你的工作区运行这个命令:

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

Then inside the project (your next/react app) where you want to install the package:然后在要安装 package 的项目(您的下一个/反应应用程序)中:

npm link <packageName>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM