node_modules

The node_modules directory is a standard directory in which modules are resolved from, initially by Node.js Module Resolution and as a result by other tools across the JavaScript ecosystem, such as Webpack, Rollup, TypeScript, and others.

Package managers take responsibility over the node_modules directory for installing external dependencies.

Installing external dependencies

External dependencies are installed using the bit install command, which encapsulates the usage of package managers, such as Yarn and PNPM, making sure component dependencies are deduped correctly and linking all Workspace Components.

bit install
CopiedCopy

Linking Workspace Components

Workspace components are linked through the node_modules directory to their location in the Workspace itself for type resolution. package.json compiled code is contained under the dist directory.

The bit link command makes sure all of Bit's core Aspects are linked to your Workspace so that you can leverage Bit's APIs.

bit link
CopiedCopy

Delegating node_modules directory to a package manager

Other package managers like NPM, Yarn and pnpm can also be used directly. To use them, configure a postinstall in your project's package.json file to make sure Workspace Component Links are generated properly and new Component Objects are imported.

note

We recommend using the bit install command for the installation and management of modules in the node_modules directory.

{
  "name": "my workspace",
  "scripts": {
    "post-install": "bit import && bit link"
  }
}
CopiedCopy