2

我有这个文件夹树:

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/*"]
}

当我从根运行时:

  • yarn 工作区包/editor_implementation 添加°一些包°
  • yarn workspace packages/* 添加°一些包°
  • lerna 添加°一些包°

所有命令都失败并带有可抽象为的消息:

知道包...

未找到包 {}...

我无法弄清楚出了什么问题,因为在我看来,我已经遵循了所有要求,如果有人有任何提示,那就太好了。

4

1 回答 1

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°

它就像一个魅力。

于 2018-09-26T15:19:15.553 回答