yarn workspace 开发示例
Posted rongfengliang-荣锋亮
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了yarn workspace 开发示例相关的知识,希望对你有一定的参考价值。
此为官方示例:
package.json
{
"private": true,
"workspaces": [
"workspace-a",
"workspace-b"
]
}
Note that the private: true
is required! Workspaces are not meant to be published, so we’ve added this safety measure to make sure that nothing can accidentaly expose them.
After this file has been created, create two new subfolders named workspace-a
and workspace-b
. In each of them, create another package.json
file with the following content:
workspace-a/package.json:
{
"name": "workspace-a",
"version": "1.0.0",
"dependencies": {
"cross-env": "5.0.5"
}
}
workspace-b/package.json:
{
"name": "workspace-b",
"version": "1.0.0",
"dependencies": {
"cross-env": "5.0.5",
"workspace-a": "1.0.0"
}
}
Finally, run
yarn install
somewhere, ideally inside the workspace root. If everything works well, you should now have a similar file hierarchy:以上是关于yarn workspace 开发示例的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Lerna + Yarn Workspaces repo 中安装 npm 包?
lerna+yarn workspace+monorepo项目的最佳实践
Yarn workspace + lerna 在每个子包中创建 node_modules
在 Yarn Workspace 的不同包中使用不同版本的依赖项