bootstrapnpm,@lerna/bootstrap 4.0.0 on npm


A tool for managing JavaScript projects with multiple packages.

NPM StatusCI Status

AboutGetting StartedHow It WorksTroubleshootingCommandslerna publishlerna versionlerna bootstraplerna listlerna changedlerna difflerna execlerna runlerna initlerna addlerna cleanlerna importlerna linklerna createlerna infoConceptsLerna.jsonGlobal FlagsFilter FlagsAbout

Splitting up large codebases into separate independently versioned packagesis extremely useful for code sharing. However, making changes across manyrepositories is messy and difficult to track, and testing across repositoriesbecomes complicated very quickly.

To solve these (and many other) problems, some projects will organize theircodebases into multi-package repositories (sometimes called monorepos). Projects like Babel, React, Angular,Ember, Meteor, Jest, and many others develop all of their packages within asingle repository.

Lerna is a tool that optimizes the workflow around managing multi-packagerepositories with git and npm.

Lerna can also reduce the time and space requirements for numerouscopies of packages in development and build environments - normally adownside of dividing a project into many separate NPM packages. See thehoist documentation for details.

What does a Lerna repo look like?

There's actually very little to it. You have a file structure that looks like this:

my-lerna-repo/package.jsonpackages/package-1/package.jsonpackage-2/package.jsonWhat can Lerna do?

The two primary commands in Lerna are lerna bootstrap and lerna publish.

bootstrap will link dependencies in the repo together.publish will help publish any updated packages.

What can't Lerna do?

Lerna is not a deployment tool for serverless monorepos. Hoisting might be incompatible with traditional serverless monorepo deployment techniques.

Getting Started

The instructions below are for Lerna 3.x.We recommend using it instead of 2.x for a new Lerna project.

Let's start by installing Lerna as a dev dependency of your project with npm.

$ mkdir lerna-repo && cd $_$ npx lerna init

This will create a lerna.json configuration file as well as a packages folder, so your folder should now look like this:

lerna-repo/packages/package.jsonlerna.jsonHow It Works

Lerna allows you to manage your project using one of two modes: Fixed or Independent.

Fixed/Locked mode (default)

Fixed mode Lerna projects operate on a single version line. The version is kept in the lerna.json file at the root of your project under the version key. When you run lerna publish, if a module has been updated since the last time a release was made, it will be updated to the new version you're releasing. This means that you only publish a new version of a package when you need to.

Note: If you have a major version zero, all updates are considered breaking. Because of that, running lerna publish with a major version zero and choosing any non-prerelease version number will cause new versions to be published for all packages, even if not all packages have changed since the last release.

This is the mode that Babel is currently using. Use this if you want to automatically tie all package versions together. One issue with this approach is that a major change in any package will result in all packages having a new major version.

Independent mode

lerna init --independent

Independent mode Lerna projects allows maintainers to increment package versions independently of each other. Each time you publish, you will get a prompt for each package that has changed to specify if it's a patch, minor, major or custom change.

Independent mode allows you to more specifically update versions for each package and makes sense for a group of components. Combining this mode with something like semantic-release would make it less painful. (There is work on this already at atlassian/lerna-semantic-release).

Set the version key in lerna.json to independent to run in independent mode.


If you encounter any issues while using Lerna please check out our Troubleshootingdocument where you might find the answer to your problem.

Frequently asked questions



Lerna will log to a lerna-debug.log file (same as npm-debug.log) when it encounters an error running a command.

Lerna also has support for scoped packages.

Run lerna --help to see all available commands and options.

lerna.json{"version": "1.1.3","npmClient": "npm","command": {"publish": {"ignoreChanges": ["ignored-file", "*.md"],"message": "chore(release): publish","registry": ""},"bootstrap": {"ignore": "component-*","npmClientArgs": ["--no-package-lock"]}},"packages": ["packages/*"]}version: the current version of the repository.npmClient: an option to specify a specific client to run commands with (this can also be specified on a per command basis). Change to "yarn" to run all commands with yarn. Defaults to "npm".command.publish.ignoreChanges: an array of globs that won't be included in lerna changed/publish. Use this to prevent publishing a new version unnecessarily for changes, such as fixing a typo.command.publish.message: a custom commit message when performing version updates for publication. See @lerna/version for more details.command.publish.registry: use it to set a custom registry url to publish to instead, you must already be authenticated if required.command.bootstrap.ignore: an array of globs that won't be bootstrapped when running the lerna bootstrap command.command.bootstrap.npmClientArgs: array of strings that will be passed as arguments directly to npm install during the lerna bootstrap command.command.bootstrap.scope: an array of globs that restricts which packages will be bootstrapped when running the lerna bootstrap command.packages: Array of globs to use as package locations.

The packages config in lerna.json is a list of globs that match directories containing a package.json, which is how lerna recognizes "leaf" packages (vs the "root" package.json, which is intended to manage the dev dependencies and scripts for the entire repo).

By default, lerna initializes the packages list as ["packages/*"], but you can also use another directory such as ["modules/*"], or ["package1", "package2"]. The globs defined are relative to the directory that lerna.json lives in, which is usually the repository root. The only restriction is that you can't directly nest package locations, but this is a restriction shared by "normal" npm packages as well.

For example, ["packages/*", "src/**"] matches this tree:

packages/├── foo-pkg│ └── package.json├── bar-pkg│ └── package.json├── baz-pkg│ └── package.json└── qux-pkg└── package.jsonsrc/├── admin│ ├── my-app│ │ └── package.json│ ├── stuff│ │ └── package.json│ └── things│ └── package.json├── profile│ └── more-things│ └── package.json├── property│ ├── more-stuff│ │ └── package.json│ └── other-things│ └── package.json└── upload└── other-stuff└── package.json

Locating leaf packages under packages/* is considered a "best-practice", but is not a requirement for using Lerna.

Legacy Fields

Some lerna.json fields are no longer in use. Those of note include:

lerna: originally used to indicate the current version of Lerna. Made obsolete and removed in v3Common devDependencies

Most devDependencies can be pulled up to the root of a Lerna repo with lerna link convert

The above command will automatically hoist things and use relative file: specifiers.

Hoisting has a few benefits:

All packages use the same version of a given dependencyCan keep dependencies at the root up-to-date with an automated tool such as SnykDependency installation time is reducedLess storage is needed

Note that devDependencies providing "binary" executables that are used bynpm scripts still need to be installed directly in each package where they'reused.

For example the nsp dependency is necessary in this case for lerna run nsp(and npm run nsp within the package's directory) to work correctly:

{"scripts": {"nsp": "nsp"},"devDependencies": {"nsp": "^2.3.3"}}Git Hosted Dependencies

Lerna allows target versions of local dependent packages to be written as a git remote url with a committish (e.g., #v1.0.0 or #semver:^1.0.0) instead of the normal numeric version range.This allows packages to be distributed via git repositories when packages must be private and a private npm registry is not desired.

Please note that lerna does not perform the actual splitting of git history into the separate read-only repositories. This is the responsibility of the user. (See this comment for implementation details)

// packages/pkg-1/package.json{name: "pkg-1",version: "1.0.0",dependencies: {"pkg-2": "github:example-user/pkg-2#v1.0.0"}}// packages/pkg-2/package.json{name: "pkg-2",version: "1.0.0"}

In the example above,

lerna bootstrap will properly symlink pkg-2 into pkg-1.lerna publish will update the committish (#v1.0.0) in pkg-1 when pkg-2 changes.README Badge

Using Lerna? Add a README badge to show it off: lerna


If you prefer some guidance for cli (in case you're about to start using lerna or introducing it to a new team), you might like lerna-wizard. It will lead you through a series of well-defined steps:

lerna-wizard demo image

Bootstrap v5 中文文档 · Bootstrap 是全球最受欢迎的 HTML ...@lerna/bootstrap 4.0.0 on npm - Libraries.ioHow to start a web app project using Bootstrap with NPM ...Angular Bootstrap - Valor Softwarenpm install bootstrap Code Example - codegrepper.comGetting Started | bootstrap-select · SnapAppointments ...@animoca/ethereum-hardhat-bootstrap NPM | npm.io14 Angular Bootstrap Modal NpmReact-Bootstrap · React-Bootstrap DocumentationIDEA项目用npm导入bootstrap/echarts包bootstrap-4.0.0vue3-bootstrap5-modal:使用Bootstrap 5的简单vue 3模态组件-源码vue-cli3引入bootstrap组件和icon插件bootstrap3-editablevue 集成bootstrap使用PUG-Bootstrap:Bootstrap框架完全使用Pug中的mixins编写-源码PUG-Bootstrap:在Pug中完全使用mixins编写的Bootstrap框架-源码bootstrap-show-modal:Bootstrap 4 jQuery插件包装器,用于在JavaScript中动态创建模式-源码unable to access ‘‘: Failed to connect to github...bootstrap-4-autocomplete:Bootstrap 4和jQuery的简单autocompletetypeahead-源码vue-cli 引入jQuery,Bootstrap,popper的方法ngx-breadcrumbs:Angular 6 + Bootstrap 4面包屑插件-源码Bootstrap-4-templates:Bootstrap 4模板-Bootstrap的材料设计-源码Bootstrap中的npm.js有什么作用bootstrap-colorpicker:Bootstrap Colorpicker是Bootstrap的模块化颜色选择器插件-源码Bootstrap Table项目初始化与自定义全局配置stagecast样式:Stagecast基础样式。 深度修改的Bootstrap主题-源码下载 SCSS,Bootstrap,Gulp4,Webpack,NPM,Live Reload,Iconfont,Sprites等合而为一-源码test-Boostrap-源码laughing-octo-train-源码test-javascript-源码getting-starting-with-bootrap-源码bootstrap-n-gulp:将Bootstrap网格系统与Bootstrap 4分开***要通过单个命令使用此软件包,请执行“ npm ...npm常用命令react-native-bootstrap:for为React Native构建的Bootstrap组件-源码react-bootstrap-icons:用于Bootstrap图标的React组件-源码