lerna ERR! EDESTDIR --dest does not match with the package directories: packages - lerna

When trying to import a repo into my lerna monorepo it keeps failing with:
lerna ERR! EDESTDIR --dest does not match with the package directories: packages
I'm using the default lerna.json config.
{
"packages": [
"packages/*",
],
"version": "0.0.0"
}
The import command I'm using is:
npx lerna import --flatten /Users/home/Desktop/Lerna_Tests/docs-repo --dest=docs
I also tried:
npx lerna import --flatten /Users/home/Desktop/Lerna_Tests/docs-repo --dest=packages/docs
However, both fail with the same error.
I want the repo to go to the packages/docs directory.

Summary
I added a directory glob entry to my lerna.json packages array and added quotes to my import command to fix it.
Explanation:
I realized that when setting up the lerna.json I was using the default lerna.json config but needed to add an entry to the packages array like this:
{
"packages": [
"packages/*",
"packages/docs/*" <<<<<<<<< I added this line.
],
"version": "0.0.0"
}
NOTE: the /* is important after the directory.
Once I added this, the following command imported my repository without a problem:
npx lerna import --flatten /Users/home/Desktop/Lerna_Tests/docs-repo --dest="packages/docs"
Note: I tried without the quotes around the destination directory and it didn't work for some reason. The docs for Lerna give an example without using quotes so I assume that it must be okay in some circumstances just not in mine.
This SO question and answer helped my fix my error. However, it was a different solution and a different problem so I thought I'd post my question answer for those whose issue relates closer to the above situation.

Related

npm publish (using also lerna) is ignoring ts definition file

Hi all I am creating this public library
https://github.com/kristijorgji/winstonjs-utils using ts+lerna monorepo
My issue is that although having specified in every package.json
"files": [
"./dist"
],
The file dist/index.d.ts is ignored by the publish command
When I build typescript , the dist folder has two files
But in the published package under dist exists only index.js
I do not have any .npmignore file as you can also see in the public repo I shared.
In all packages packages.json I have specified the typings as well
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"./dist"
],
Any idea why index.d.ts is excluded from the published packages ? Thanks
I managed to find one solution although might not be the best one.
Nevertheless I am posting in lack of an answer to help everyone facing same issue as me
Solution: I used .npmignore instead of files in package.json
files key seem broken because it ignores index.d.ts files
I used a .npmignore file that excludes unecessary things like
__tests__
coverage
src
tasks
.eslintrc.js
jest.config.js
nodemon.debug.json
nodemon.json
tsconfig.json
then publishing the package worked great with same result as I intended, having only dist folder with index.js index.d.ts inside and package.json and readme.md

Yarn installing wrong version of jest in workspace

I have a project with yarn (v1) workspaces.
project/
packages/
pkgA/
subPkgA1/
pkgB/
package.json has this:
"workspaces": {
"packages": [
"packages/pkgA",
"packages/pkgA/subPkgA1",
"packages/pkgB"]}
note that there's a nested workspace in there.
Top-level has jest#27.4.7 in its package.json.
pkgA has jest#24.9.0 because one of its dependencies requires that version; its package.json has no entry for jest.
pkgA/subPkgA1 has jest#27.4.7 in its package.json, BUT it actually gets 24.9.0 installed in its node_modules/.bin/jest, presumably because its parent workspace has that.
My main question is how to get jest#27.4.7 in the nested package subPkgA1? I tried adding an entry in pkgA's package.json, but that didn't help.
BTW, I know nested workspaces aren't fully supported until Yarn v2, but I can't upgrade right now, and I can't easily move my subpackage out of its parent, so any hacky solution would be better than nothing.

Yarn install a single package to single workspace

This is my project set up
proj:
package.json - workspaces["app/frontend", "app/backend"]
app
frontend - package.json
backend - package.json
say I cd to proj
I want to do yarn workspace app/frontend add uuid -dev (add a pkg to one of the workspace)
err is Unknown workspace "app/frontend", wonder what is the correct syntax?
yarn workspace frontend add uuid --save-dev
When you define your workspaces in the package.json you should use relative path to the workspace:
"workspaces": [
"app/frontent",
"app/backend"
]
However, when you refer to your workspace in yarn workspace ... command you should use the package name of this workspace (including namespace).
For example, if your frontend/package.json defines
{
name: "#myproj/frontend".
...
}
you will use
yarn workspace #myproj/frontent add uuid --save-dev

Yarn errors with Not Found for local Lerna packages

Calling yarn commands inside a package that references a local lerna package fails with
- packages
- package1
- package2
say package2 references package1
dependencies: [
"#my-scope/package1": "^1.0.0"]
When I run any yarn command in package2 e.g. yarn add, or yarn list I get an error:
An unexpected error occurred: "https://registry.yarnpkg.com/#myscope%2package1: Not found".
I have run lerna bootstrap at the top level with
"npmClient": "yarn"
which successfully builds all my packages and the node_modules of package2 contains package1, however the yarn.lock file does not have any of the local packages
What might I be doing wrong?
Your dependence version should match origin's version, otherwise, yarn will lookup by internet instead local package
Say
packages1's package.json:
{
"name": "#my-scope/package1",
"version": "0.0.1"
}
packages2's package.json:
{
"name": "#my-scope/package2",
"dependencies": {
"#my-scope/package1": "^1.0.0"
}
}
yarn can's find that version match ^1.0.0, so it just try fetch from yarnpkg.com

Cannot find module 'rxjs-compat/Subscription'

I am trying to migrate from rx5 to rx6 by following the guide here. Initially, I installed along with the rxjs-compat package and everything works fine. However, when I try to remove the rxjs-compat package, I am getting an exception Cannot find module 'rxjs-compat/Subscription'. I used the rxjs-5-to-6-migrate to perform the migration
I am using this statement for Subscription : import { Subscription } from "rxjs";
For reference this is my branch- https://github.com/akshita31/omnisharp-vscode/tree/rxjs_update and this is the corresponding pull request that lists all the changes - https://github.com/OmniSharp/omnisharp-vscode/pull/2830
I updated all the dependencies to the latest versions and used the rxjs-tslint-rules as follows
npm install rxjs-tslint-rules --save-dev
Then in my tslint.json add the rule "rxjs-no-compat" : true
Execute ./node_modules/.bin/tslint -c tslint.json -p tsconfig.json in the project folder. This will give all the set of invalid imports
Resolve the invalid imports and then try removing the rxjs-compat package.
I also cleaned my npm cache - npm cache clean --force
If there are no more errors, we can as well remove the above tslint dependency from the package.json
More details can be found in the issue.
Thanks #cartant for the help
Do you by any chance still have some imports that are still using rxjs-compat?
With the migration from rxjs 5 to 6, you need to be very careful about all the imports, since you don't want to import some module from wrong the wrong path. I believe rxjs-tslint can help you.

Resources