A standard node package is one of the artifacts generated for a Bit component during its build. This allows us to install components as packages in projects with or without a Bit workspace initialized.
Head over to bit.cloud to find the components you need.
Run the following command to install a component, using Bit, in a project that has a Bit workspace initialized (this is useful when you want to use a component in your workspace, without modifying it):
The package is installed in your workspace's node_modules
directory. The workspace.jsonc
is updated with the new dependency:
/* @filename: workspace.jsonc */ { "teambit.dependencies/dependency-resolver": { "packageManager": "teambit.dependencies/pnpm", "policy": { "dependencies": { "@teambit/design.inputs.dropdown": "^1.2.18" }, } } }
To install a component in a project using a standard package manager, first set your package manager to use Bit's registry.
Run the following command to install a component, using your package manager, in any project (Bit and non-Bit):
The package is installed in your project's node_modules
directory. Your package.json
is updated with the new dependency:
/* @filename: package.json */ { "name": "my-non-bit-project", "dependencies": { "@teambit/design.inputs.dropdown": "^1.2.18" } }
To use a component, import/require it as you would do with any other package:
import { Dropdown } from '@teambit/design.inputs.dropdown';
We highly recommend using Bit to install components in a Bit workspace
To configure your package manager to use Bit's registry, when installing components from a specific scope, add the following line to the .npmrc
file of your project, user, or machine:
This can be done by adding the following line to the .npmrc
file:
For example, if your Bit account name is our-awesome-company
, the .npmrc
file should look like this:
To authenticate with the registry, in case of a private scope, set Bit cloud with an auth token that has access to the scope.
//node.bit.cloud/:_authToken=USER_AUTH_TOKEN
Replace BIT_USER_TOKEN
with a bit auth token that has the right permissions.
To get a Bit user token, first log in to your Bit account from a machine that has Bit installed:
Run the following command to get your Bit user token:
The output should be similar to this:
When self hosting Bit on your own server you need to publish the components as packages to any package registry. The authentication process for the package manager is very much the same other then the fact you can't use bit login
to set your token.