Install Components

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):

$bit
Copiedcopy
See command synopsis

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"
      },
    } 
  }
}
CopiedCopy

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):

$npm i @teambit/design.inputs.dropdown
Copiedcopy

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"
  }
}
CopiedCopy

To use a component, import/require it as you would do with any other package:

import { Dropdown } from '@teambit/design.inputs.dropdown';
CopiedCopy
We highly recommend using Bit to install components in a Bit workspace

Configure your package manager to use Bit's registry

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:

@MY_BIT_ACCOUNT:registry=https://node.bit.cloud

For example, if your Bit account name is our-awesome-company, the .npmrc file should look like this:

@our-awesome-company:registry=https://node.bit.cloud

To authenticate with the registry, in case of a private scope, set Bit cloud with an auth token that has access to the scope.

@MY_BIT_ACCOUNT:registry=https://node.bit.cloud
//node.bit.cloud/:_authToken=USER_AUTH_TOKEN

Replace BIT_USER_TOKEN with a bit auth token that has the right permissions.

User auth token

To get a Bit user token, first log in to your Bit account from a machine that has Bit installed:

$bit
Copiedcopy
See command synopsis

Run the following command to get your Bit user token:

$bit
Copiedcopy
See command synopsis

The output should be similar to this:

b8b9d516-234a-4ad7-ae9e-701a78y189ne

For Self-hosted Components

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.