@0x-lerna-fork/bootstrap

中文文档
3.16.3发布于 2019/07/23MITCommonJS近 30 天下载 1903

Link local packages together and install remaining package dependencies

原始使用文档
文档目录15 节
  1. Usage
  2. --hoist [glob]
  3. --strict
  4. --nohoist [glob]
  5. --ignore
  6. Options
  7. --ignore-prepublish
  8. --ignore-scripts
  9. --registry <url>
  10. --npm-client <client>
  11. --use-workspaces
  12. --no-ci
  13. --force-local
  14. How It Works
  15. Notes

@0x-lerna-fork/bootstrap

Link local packages together and install remaining package dependencies

Install lerna for access to the lerna CLI.

Usage

$ lerna bootstrap

Bootstrap the packages in the current Lerna repo. Installs all of their dependencies and links any cross-dependencies.

When run, this command will:

  1. npm install all external dependencies of each package.
  2. Symlink together all Lerna packages that are dependencies of each other.
  3. npm run prepublish in all bootstrapped packages (unless --ignore-prepublish is passed).
  4. npm run prepare in all bootstrapped packages.

lerna bootstrap respects the --ignore, --scope and --include-filtered-dependencies flags (see Filter Flags).

Pass extra arguments to npm client by placing them after --:

$ lerna bootstrap -- --production --no-optional

May also be configured in lerna.json:

{
  ...
  "npmClient": "yarn",
  "npmClientArgs": ["--production", "--no-optional"]
}

--hoist [glob]

Install external dependencies matching glob at the repo root so they're available to all packages. Any binaries from these dependencies will be linked into dependent package node_modules/.bin/ directories so they're available for npm scripts. If the option is present but no glob is given the default is ** (hoist everything). This option only affects the bootstrap command.

$ lerna bootstrap --hoist

For background on --hoist, see the hoist documentation.

Note: If packages depend on different versions of an external dependency, the most commonly used version will be hoisted, and a warning will be emitted.

--strict

When used in conjunction with hoist will throw an error and stop bootstrapping after emitting the version warnings. Has no effect if you aren't hoisting, or if there are no version warnings.

$ lerna bootstrap --hoist --strict

--nohoist [glob]

Do not install external dependencies matching glob at the repo root. This can be used to opt out of hoisting for certain dependencies.

$ lerna bootstrap --hoist --nohoist=babel-*

--ignore

$ lerna bootstrap --ignore component-*

The --ignore flag, when used with the bootstrap command, can also be set in lerna.json under the command.bootstrap.ignore key. The command-line flag will take precedence over this option.

Example

{
  "version": "0.0.0",
  "command": {
    "bootstrap": {
      "ignore": "component-*"
    }
  }
}

Hint: The glob is matched against the package name defined in package.json, not the directory name the package lives in.

Options

--ignore-prepublish

Skip prepublish lifecycle scripts run by default in bootstrapped packages. Note, this lifecycle is deprecated, and will likely be removed in the next major version of Lerna.

$ lerna bootstrap --ignore-prepublish

--ignore-scripts

Skip any lifecycle scripts normally run (prepare, etc) in bootstrapped packages.

$ lerna bootstrap --ignore-scripts

--registry <url>

When run with this flag, forwarded npm commands will use the specified registry for your package(s).

This is useful if you do not want to explicitly set up your registry configuration in all of your package.json files individually when e.g. using private registries.

--npm-client <client>

Must be an executable that knows how to install npm package dependencies. The default --npm-client is npm.

$ lerna bootstrap --npm-client=yarn

May also be configured in lerna.json:

{
  ...
  "npmClient": "yarn"
}

--use-workspaces

Enables integration with Yarn Workspaces (available since [email protected]+). The values in the array are the commands in which Lerna will delegate operation to Yarn (currently only bootstrapping). If --use-workspaces is true then packages will be overridden by the value from package.json/workspaces. May also be configured in lerna.json:

{
  ...
  "npmClient": "yarn",
  "useWorkspaces": true
}

The root-level package.json must also include a workspaces array:

{
  "private": true,
  "devDependencies": {
    "lerna": "^2.2.0"
  },
  "workspaces": ["packages/*"]
}

This list is broadly similar to lerna's packages config (a list of globs matching directories with a package.json), except it does not support recursive globs ("**", a.k.a. "globstars").

--no-ci

When using the default --npm-client, lerna bootstrap will call npm ci instead of npm install in CI environments. To disable this behavior, pass --no-ci:

$ lerna bootstrap --no-ci

To force it during a local install (where it is not automatically enabled), pass --ci:

$ lerna bootstrap --ci

This can be useful for "clean" re-installs, or initial installations after fresh cloning.

--force-local

$ lerna bootstrap --force-local

When passed, this flag causes the bootstrap command to always symlink local dependencies regardless of matching version range.

How It Works

Let's use babel as an example.

  • babel-generator and source-map (among others) are dependencies of babel-core.
  • babel-core's package.json lists both these packages as keys in dependencies, as shown below.
// babel-core package.json
{
  "name": "babel-core",
  ...
  "dependencies": {
    ...
    "babel-generator": "^6.9.0",
    ...
    "source-map": "^0.5.0"
  }
}
  • Lerna checks if each dependency is also part of the Lerna repo.
    • In this example, babel-generator can be an internal dependency, while source-map is always an external dependency.
    • The version of babel-generator in the package.json of babel-core is satisfied by packages/babel-generator, passing for an internal dependency.
    • source-map is npm installed (or yarned) like normal.
  • packages/babel-core/node_modules/babel-generator symlinks to packages/babel-generator
  • This allows nested directory imports

Notes

  • When a dependency version in a package is not satisfied by a package of the same name in the repo, it will be npm installed (or yarned) like normal.
  • Dist-tags, like latest, do not satisfy semver ranges.
  • Circular dependencies result in circular symlinks which may impact your editor/IDE.

Webstorm locks up when circular symlinks are present. To prevent this, add node_modules to the list of ignored files and folders in Preferences | Editor | File Types | Ignored files and folders.

版本与发布记录

@0x-lerna-fork/bootstrap 共发布 3 个版本,首次发布于 2018/07/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.16.3latest2019/07/237 年前
3.16.22019/07/237 年前
3.0.0-beta.222018/07/258 年前

关于 @0x-lerna-fork/bootstrap 的常见问题

@0x-lerna-fork/bootstrap 是什么?

Link local packages together and install remaining package dependencies

如何安装 @0x-lerna-fork/bootstrap?

在项目目录运行 npm install @0x-lerna-fork/bootstrap,或使用 pnpm add / yarn add / bun add。

@0x-lerna-fork/bootstrap 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/0x-lerna-fork__bootstrap 是否存在。

@0x-lerna-fork/bootstrap 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@0x-lerna-fork/bootstrap 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 6.9.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@0x-lerna-fork/bootstrap 可以商用吗?

@0x-lerna-fork/bootstrap 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@0x-lerna-fork/bootstrap 的下载量有多少?

根据 npm 官方下载统计,@0x-lerna-fork/bootstrap 在 2026/10/04 – 2026/11/02 这 30 天内被下载 1,903 次,日均约 63 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@0x-lerna-fork/bootstrap 还在维护吗?

最新版本 3.16.3 发布于 2019/07/23(7 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/07/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。