Lerna简介
Lerna是一个优化基于git + npm的多package项目的管理工具
优势
- 大幅减少重复操作
- 提升操作的标准化
Lerna是架构优化的产物,它揭示一个架构真理:项目复杂度提升后,就需要对项目进行架构优化。架构优化的主要目标往往都是以效能为核心。
官网
案例
使用Lerna管理的大型项目:
- babel:https://github.com/babel/babel
- vue-cli:https://github.com/vuejs/vue-cli
- create-react-app:https://github.com/facebook/create-react-app

lerna命令
-
查看帮助文档:lerna add -h
-
初始化:lerna init
-
创建包:lerna create core
创建core包
-
清除依赖:lerna clean
-
安装到指定的目录下:lerna add @imooc-cli/utils packages/core/
-
重装依赖:lerna bootstrap
-
链接依赖:lerna link
-
删除所有的packages下的所有node_modules:lerna exec -- rm -rf node_modules/
-
查看版本:lerna version
-
哪些packages做了变更:lerna changed
-
lerna diff
-
发布
登录npm:npm login
执行npm login
执行npm publish发包到npm上:lerna publish
执行npm publish发包到npm上
查看是否发布成功

查看当前登录的用户:npm whoami
- 删除指定的依赖
npm remove -g @hjy-cli/utils
Lerna源码分析
源码仓库地址:https://github.com/lerna/lerna
Lerna启动命令 core/lerna/cli.js ls

debug
Step Over F10:一行一行往下执行(不会进入importLocal方法里)

Step Into F11:进入到函数里面执行(会进入到importLocal方法里面)

Step Out F8:进入到函数里,不希望再往里面跳,可以跳出来(与F11相反)
Evaluate Expression 实时运算


Resume Program 直接跳到对应断点位置

网友评论