lerna 始终导入 returns EDESTDIR

lerna import always returns EDESTDIR

我有一个预先存在的项目,我想将其导入到我现有的使用 yarn 工作区的 lerna monorepo 中。

命令:

I've tried running all of the following commands. The error remains stubbornly unchanged. Also, petstore has a package.json file and is a git repo.

lerna import ./petstore --dest="./packages/"
lerna import ./petstore --dest="./packages/api/"

错误:

lerna notice cli v3.20.2
lerna ERR! EDESTDIR --dest does not match with the package directories: packages/**

Also, lerna import ../petstore results in a packages/**/petstore being created which is not an expected result.

我希望这包含所有相关代码。我们在 packages/shared 下有支持包,在 packages/api.

下有 api

lerna.json

{
  "packages": [
    "packages/**/*"
  ],
  "npmClient": "yarn",
  "useWorkspaces": true,
  "private": true,
  "version": "0.0.1",
  "lerna": "2.11.0"
}

package.json

{
  "name": "root",
  "devDependencies": {
    "lerna": "^2.11.0"
  },
  "workspaces": [
    "packages/**/*"
  ],
}

我看过的资源:

Lerna 从 package.json 上的键 workspaces 而不是 lerna.json 上的 packages 读取包。

lerna 读取带有 /* 的所有值并将它们视为包目录。它按字面解释 ** 并且不将其解析为通配符并展开它。

解决方案是从 lerna.json 中删除 packages:

{
  "npmClient": "yarn",
  "useWorkspaces": true,
  "private": true,
  "version": "0.0.1",
  "lerna": "2.11.0"
}

如果你的 monorepo 是这样构建的,并更新工作区路径以明确引用包中的任何子目录:

{
  "name": "root",
  "devDependencies": {
    "lerna": "^2.11.0"
  },
  "workspaces": [
    "packages/a/*",
    "packages/api/*"
  ],
}

要将 pet-store 项目从 mono-repo 之外的目录导入到 monorepo 中的 packages/api

lerna import ../pet-store --dest="./packages/api/"