如何通过纱线工作区在应用程序中添加多个工作区

时间:2018-05-29 07:15:18

标签: yarnpkg yarn-workspaces

我正在创建一个依赖于模块的应用程序。应用程序的文件结构是......

demo-app
|
|----package.json("workspaces": ["module-core/packages/*","src/packages/*" ])
|----src/
|    |---packages/
|        |---package.json ("workspaces": ["packages/*"])
|        |---module-a
|            |---package.json("name":"@app/module-a","private":true, "workspaces": ["packages/*"])
|        |---module-b
|            |---package.json("name":"@app/module-b","private":true, "workspaces": ["packages/*"])
|
|----module-core/
|    |---package.json ("workspaces": ["packages/*"])
|    |---packages/
|        |---core-a
|            |---package.json("name":"@app/core-a","private":true, "workspaces": ["packages/*"])
|        |---core-b
|            |---package.json("name":"@app/core-b","private":true, "workspaces": ["packages/*"])

下面, @app/module-a 依赖于 @app/core-a @app/module-b 依赖于 {{1} }

我在演示应用 @app/core-b 中创建了一个工作区。

运行"workspaces": ["module-core/packages/*","src/packages/*"]时出现提示错误yarn install

是否在工作区管理中缺失?

1 个答案:

答案 0 :(得分:1)

我只需启用属性"private":true

即可构建工作区

file:demo-app / package.json

{
  "version": "1.0.0",
  "private": true,
  "workspaces": ["module-core/packages/*","src/packages/*"]
  ......
  ......
}

注意:工作区中的包的顺序很重要。