I think it's hard winning a war with words.
— Gone with the wind
I think it's hard winning a war with words.
Lerna is a tool that optimizes the workflow around managing multi-package repositories with git and npm.
痛点一:重复操作
痛点二:版本一致性
Lerna is a tool that optimizes the workflow around managing multi-package repositories with git and npm.
使用 Lerna 管理的大型项目:
npm install -g lerna
git init jun-cli && cd jun-cli
lerna init
lerna create @jun-cli/core packages
lerna add mocha packages/core --dev
lerna clean
lerna run test
lerna run test @jun-cli/core
lerna link
lerna publish
会自动完成 git 初始化,但不会创建.gitignore
,,这个必须要手动添加,否则会将node_modules
目录都上传到git,如果node_modules
已经加入git stage
,可使用:
git reset HEAD <file>
执行 unstage 操作,如果文件已经被 git 监听到变更,可使用:
git checkout -- <file>
将变更作废,记得在执行操作之前将文件加入.gitignore
。
选项:
--dev
:将依赖安装到devDependencies
,不加时安装到dependencies
。lerna add <package> [loc] --dev
如果未发布上线,需要手动将依赖添加到package.json
, 再执行lerna link
。
只会删除node_modules
,不会删除package.json
中的依赖。
--scope
属性后添加的是包名,而不是 package 的路径,这点和lerna add
用法不同。
git add package-lock.json
,所以package-lock.json
不要加入 .gitignore
。master
分支。lerna publish
前先完成npm login
。npm
包名为:@xxx/yyy
的格式,需要先在npm
注册名为:xxx 的 organization,否则可能会提交不成功。npm group
时默认为private
,所以我们需要手动在package.json
中添加如下配置:"publishConfig": {
"access": "public"
}
评论没有加载,检查你的局域网
Cannot load comments. Check you network.