Lerna 是 JavaScript/TypeScript 的原始单体库工具。它已经存在多年,被成千上万的项目使用,包括 React 和 Jest。Lerna 解决了 JavaScript/TypeScript 单体库的两个最大问题:
以下是使用 Lerna 的步骤:
lerna.json
的配置文件。package.json
文件中已经配置了 workspaces
:
{ "private": true, "workspaces": "packages/*" }
这里的 "packages/*" 表示你的工作区中的包都在 packages 文件夹下。lerna.json
does not exist, have you run lerna init
? error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
这是因为没有初始化 Lerna,和上面讲到的一样,执行命令:
npx lerna initworkspaces
, and you have not explicitly specified any packages to operate on lerna ERR! See https://lerna.js.org/docs/getting-started#adding-lerna-to-an-existing-repo for how to resolve this
这是因为项目根目录的 package.json
文件中已经配置了 workspaces
,在 package.json
文件中添加如下配置:
{ "private": true, "workspaces": "packages/*" }未经允许不得转载:Web前端开发资源网 » Lerna的使用及报错问题分析解决