Publishing to CommonJS registries

Component packages are included in the component snaps. Components hosted on Bit Cloud will have their packages available to be installed by Bit, as well as by standard package managers like npm and Yarn.

However, if you're using self-hosted scopes, packages will not be available for installation \

You can install packages hosted on Bit Cloud, in non-Bit projects, by configuring your npmrc to use Bit Cloud.

Packages can also be published to commonJS package registries like npm. Components that are configured to be published to a commonJS package registry, will be published during their tag process.

bit tag ui/heading
CopiedCopy
...
new components
(first version for components)
     > ui/heading@0.0.1


published the following 1 component(s) successfully
@my-npm-scope/ui.heading@0.0.1
CopiedCopy

Use bit publish to manually publish components from the workspace (not recommended!):

bit publish ui/heading
CopiedCopy

Publish your Components to npm

Configure your components to use a different package name by setting the name property with a new name. This will set them to be published to the npm's registry (no need to configure the publishConfig property, as well).

You can use the {name} and {scope} placeholders to inject each component name, and scope name, to the corresponding package name. The package name should be prefixed with the npm scope (see the example below).

To make your packages public, configure the private and packageManagerPublishArgs properties, accordingly (see the example below).

{
  "teambit.workspace/variants": {
    "*": {
      "teambit.pkg/pkg": {
        // "packageManagerPublishArgs": ["--access public"],
        "packageJson": {
          //   "private": false,
          "name": "@my-npm-scope/{name}"
        }
      }
    }
  }
}
CopiedCopy
make sure you're logged in to npm
npm login
CopiedCopy

Publish your components to any commonJS package registry

Set the registry property to your registry's URL. Set the scope value to the specific scope in the registry.

To make your packages public, configure the private and packageManagerPublishArgs properties, accordingly (see the example below).

"teambit.workspace/variants": {
  "*": {
      "teambit.pkg/pkg": {
        // "packageManagerPublishArgs": [
        //   "--access public"
        // ],
        "packageJson": {
          "name": "@my-scope/{name}",
        //   "private": false,
          "publishConfig": {
            "scope": "@my-scope",
            "registry": "https://registry.something.org/"
          }
        }
      }
    }
}
CopiedCopy