lerna import always returns EDESTDIR

微笑、不失礼 提交于 2021-01-28 03:23:44

问题


I have a pre-existing project that I'd like to import into my existing lerna monorepo that uses yarn workspaces.

Command(s):

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/"

ERROR:

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.

I hope this consists of all the relevant code. We have supporting packages under packages/shared and apis under packages/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/**/*"
  ],
}

Resources I have looked at:

  • Lerna troubleshooting page but it does not have any info on this error.

  • Lerna Github Issue #1872

  • Lerna Github Issue #1197

  • Lerna Slack Link Broken


回答1:


Lerna reads the packages from the key workspaces on package.json instead of the packages on lerna.json.

lerna reads all the values with a /* and considers them package directories. It interprets ** literally and does not parse it as a wildcard and expand it.

The solution is to remove packages from lerna.json:

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

and update the workspaces path to refer to any sub-directories in your packages explicitly if your monorepo is structured that way:

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

To import the pet-store project into packages/api in the monorepo from a directory outside the mono-repo:

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


来源:https://stackoverflow.com/questions/60254487/lerna-import-always-returns-edestdir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!