I have a pre-existing project that I'd like to import into my existing lerna monorepo that uses yarn workspaces.
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 apackages/**/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
.
{
"packages": [
"packages/**/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"private": true,
"version": "0.0.1",
"lerna": "2.11.0"
}
{
"name": "root",
"devDependencies": {
"lerna": "^2.11.0"
},
"workspaces": [
"packages/**/*"
],
}
Lerna troubleshooting page but it does not have any info on this error.
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/"