【问题标题】:Yarn - Workspaces - Lerna - I fail to use the workspaces feature to add my packagesYarn - 工作区 - Lerna - 我无法使用工作区功能添加我的包
【发布时间】:2018-09-26 14:49:32
【问题描述】:

我有这个文件夹树:

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 运行时:

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

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

不知道包...

找不到包{}...

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

【问题讨论】:

    标签: npm yarnpkg lerna yarn-workspaces


    【解决方案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°
    

    它就像一个魅力。

    【讨论】:

    • 现在我正在搜索 yarn workspace 以在同一机芯的所有包上添加模块。
    猜你喜欢
    • 1970-01-01
    • 2022-09-27
    • 2019-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-10
    • 2020-07-31
    • 2021-08-21
    • 2019-06-26
    相关资源
    最近更新 更多