3

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

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依赖于@app/core-b

我在演示应用程序中创建了一个工作区"workspaces": ["module-core/packages/*","src/packages/*"]

运行yarn install时提示错误Couldn't find package "@app/module-a@^0.0.0" required by "@app/module-a@0.1.0" on the "npm" registry

工作区管理中是否缺少它?

4

1 回答 1

2

我只需启用该属性就可以构建工作区"private":true

文件:demo-app/package.json

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

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

于 2018-05-29T12:19:29.923 回答