纱线-工作区-莱纳-我无法使用工作区功能来添加我的包裹

时间:2018-09-26 14:49:32

标签: npm yarnpkg lerna yarn-workspaces

我有这个文件夹树:

my_project_tree 
|
├── lerna.json
├── package.json
├── package-lock.json
├── packages
│   └── editor_implementation
│       ├── dist
│       ├── package.json
│       └── src
│          
├── yarn-error.log
└── yarn.lock

我的editor_implementation / package.json具有以下内容:

{
  "name": "@my_project_tree/editor_implementation",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT"
}

我的根文件夹my_project_tree / package.json具有以下内容:

{
  "name": "hocotext",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "workspaces": [
    "packages/*"
  ],
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^6.0.0"
  },
  "devDependencies": {
    "lerna": "^3.4.0"
  }
}

我在根目录下的lerna.json具有以下内容:

{
  "version": "patch",
  "command": {
    "publish": {
      "ignoreChanges": [
          "ignored-file",
          "node_modules",
          "*.md"
      ]
    },
    "bootstrap": {
      "ignore": "component-*",
      "npmClientArgs": ["--no-package-lock"]      
    }
  },
 "npmClient": "yarn",
 "useWorkspaces": true,
 "packages": ["packages/*"]
}

当我从root运行时:

  • 纱线工作区软件包/ editor_implementation添加一些软件包°
  • 纱线工作区软件包/ *添加°一些软件包°
  • lerna添加一些包裹°

所有命令均失败,并显示一条消息,摘要为:

  

了解软件包...

     

找不到包裹{} ...

我不知道出什么问题了,因为在我看来,我遵循所有要求,如果有人有任何暗示,那就太好了。

1 个答案:

答案 0 :(得分:1)

为了发现您的工作区,只需运行:

yarn workspaces info

就我而言,它返回:

{
  "@hoco_editor/editor_implementation": {
    "location": "packages/editor_implementation",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  }
}

所以我已经使用@ hoco_editor / editor_implementation运行命令,如下所示:

 yarn workspace @hoco_editor/editor_implementation add °some packages°

它就像一种魅力。