gpt4 book ai didi

node.js - lerna 导入总是返回 EDESTDIR

转载 作者:行者123 更新时间:2023-12-04 15:34:20 24 4
gpt4 key购买 nike

我有一个预先存在的项目,我想将其导入到我现有的使用 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/"

关于node.js - lerna 导入总是返回 EDESTDIR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60254487/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com