-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
背景
项目包含多包的解决方案
安装 lerna
# 适用 nvm 安装 node 时,yarn global add lerna 还是 ~/.yarn/bin,所以建议适用 npm i lerna -g
yarn global add lerna
npm install lerna -g初始化项目
useWorkspaces 是 yarn 的特性,不是 lerna
lerna init
lerna init --independent默认模式和 independent 模式的区别:https://github.com/lerna/lerna#fixedlocked-mode-default
lerna 的 useWorkspaces 与 yarn 的 workspace
lerna init --independentlerna 的 useWorkspaces
{
"lerna": "independent",
"npmClient": "yarn",
"useWorkspaces": true
}yarn 的 workspace 配置
根目录 package.json 中配置 workspaces 字段:
{
...
"private": true,
"workspaces": [
"packages/*"
]
...
}设置 package.json 的 workspaces 是使用useWorkspaces 配置的前提。
- 如果只设置了
useWorkspaces新增模块时,提示需要设置package.json的workspaces字段。
lerna create module-c
lerna notice cli v3.20.2
lerna info versioning independent
lerna ERR! EWORKSPACES Yarn workspaces need to be defined in the root package.json.
lerna ERR! EWORKSPACES See: https://github.com/lerna/lerna/blob/master/commands/bootstrap/README.md#--use-workspaces
useWorkspaces 的前提是 useWorkspaces
- 如果没有设置
package.json的workspaces字段,以下初始化也会报错。
lerna init --indepentent --use-workspaces参考文档
https://github.com/lerna/lerna
https://classic.yarnpkg.com/blog/2017/08/02/introducing-workspaces/
Metadata
Metadata
Assignees
Labels
No labels
