How do I… work with Bit, Frequently Asked Questions (FAQs).
… install Bit?
To install Bit use one of the various options of installation: for Mac, Windows or Linux machines. See installation methods.
We recommend installing with NPM.
… authenticate my CLI with Bit?
… initialize Bit on my project?
You can use the
bit init command to initialize Bit for your local project. See Initializing Bit.
… track and isolate components in my repository?
bit add command you can point Bit to directories and files in your repository so it can track them as components. See Isolating and Tracking Components.
You can untrack a component using the
bit untrack command.
… handle component dependencies?
When you use
bit tag to version a component, Bit reads through the files and looks for
require statements, Bit uses them to resolve the component’s dependency graph, including packages and other files in the project. Bit does this in order to figure out all data required to create an isolated component environment for the component.
You can also manually add missing dependencies when needed.
… track components with a custom module definition in a project?
If you are using custom module definition, you need to configure it in your project’s
bit.json file, so Bit will resolve your dependencies properly. There’s an example for it here. You can also find more information in the bit.json configuration doc.
… add build and test environments for the components?
Component’s Build and Test steps are implemented in Bit as a special type of extension called ‘Environment’. Environments are Bit components, and are managed in Scopes, versioned and shared across projects.
A component can have a Build or Test environment defined to it. When configured, Bit can run these steps on the component, in its isolated environment.
For example, when you define a Build step to your component, Bit is able to create a
dist for that individual component. And once you define a Test environment, Bit runs the component’s tests in complete isolation, verifying it can truly be isolated from the project and reused in a different one.
Bit has some pre-made environments that you can use.
… see the status of my components at any given moment?
bit status command to see which components are tracked, modified etc any time you need.
… version tracked components?
Before sharing your components to be used in other projects, you can version the components using the
bit tag command. See versioning components.
untag a component using the
bit untag command.
… share (export) components?
… find components?
One of the most painful problems with shared code is discoverability. Discoverability means two things: being able to find what’s out there, and learning about it’s quality and functionality.
Every component shared with Bit is organized in a Scope, which works as a curated collection. Components can also be searched and found via a designated component search-engine.
… evaluate a component before using it?
There are several features implemented in BIt that allows you to view and evaluate components before you install them in your project.
- Docs - Bit parses JSDocs and .md files to automatically present documentation and example for the components whenever possible.
- Tests - Test results are presented for every component whenever test files are tracked as part of the component. This helps monitor component quality and understand how it works.
- Visualization - Bit uses a live playground to render an visualize UI components and interactively enable you to play with them before choosing to use them.
… preview React UI components?
… install components with NPM/Yarn?
… import and modify components?
A component can be imported and modified from any repository, not just the one it’s exported from. To modify a component from a different project you can
bit import the component into the project and make the changes you need to its source code. See importing components.
Bit will track the component in every repository it’s imported to, so that you can later update and merge changes to components between different repositories using the remote Scope as a source of truth.
… update components?
You can use Bit to import updated component versions and even leverage bit diff to understand the differences between then. To learn more about updating components and handling versions see updating sourced components.
Note: When you run
bit status, Bit will inform you if there are pending updates for your components. Use
bit import to updates all sourced components. See more here.
… merge changes to components between different repositories?
After you imported Bit components in to your codebase, you can modify them locally and merge the local modification with all incoming updates from remote Scopes. When you import a newer version of a modified component, Bit will try to use Git in order to do an automated merge between them. If this fails, Bit will prompt you to manually resolve the merge conflict. See merging component changes.
… rename a directory of file within a component?
Use the bit move to rename files and directories within a component.
… export my component local changes as a new version?
Note: You can use the
--eject flag to move the component back to being a package dependency in the project.