Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lerna add : No packages found where <package> can be added

have added lerna to my project, i have added a package to my server by running this command successfully:

 lerna add  @types/express --dev

But when I want to add another one:

lerna add graphql class-validator type-graphql

I got this error :

info cli using local version of lerna
lerna notice cli v3.22.1
lerna WARN No packages found where graphql can be added. 
  1. Is something missed or wrong for adding the packages?
  2. Should I use yarn add instead of leran add? looks it works but I doubt about the packages tree form to be correct
like image 927
Amir Meyari Avatar asked Jul 19 '20 13:07

Amir Meyari


People also ask

What does lerna add do?

Lerna comes with an add command to install NPM dependencies in your project's packages. By default, lerna adds a new dependency to all managed packages. That's it! You can now use the added dependency in the related package.

What is lerna link?

Lerna is a fast modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.

What does lerna Exec do?

Profiles the command executions and produces a performance profile which can be analyzed using DevTools in a Chromium-based browser (direct url: devtools://devtools/bundled/devtools_app.html ). The profile shows a timeline of the command executions where each execution is assigned to an open slot.


3 Answers

At the moment, lerna doesn't support adding multiple packages to another package like so:

❌ lerna add '@my-company/{utils,types}' --scope '@my-company/ui' 

// We have to do this instead
lerna add '@my-company/utils' --scope '@my-company/ui' 
lerna add '@my-company/types' --scope '@my-company/ui'

Lerna does support adding 1 package into multiple packages though:

lerna add '@my-company/utils --scope '@my-company/{ui,data}'   

lerna's github discussion on this issue for updates (link)

like image 128
Clifford Fajardo Avatar answered Oct 27 '22 07:10

Clifford Fajardo


Lerna add does not support multiple packages, try doing one at a time.

lerna add graphql
lerna add class-validator
lerna add type-graphql

There is an issue to support this on github that will hopefully be resolved one day

like image 24
Frank Avatar answered Oct 27 '22 08:10

Frank


Foreword: The lerna cli is notoriously bad at giving feedback. You get weird errors and warnings that don't seem to make a lot of sense in the context.

Why is this happening?

I identified the following causes (at one point or another) to all result in this error message:

  1. You already added the package to given package.
    • This is somewhat irritating, since with yarn and npm you can (force) re-install a package, instead of having it error out.
  2. You tried to add multiple packages in one command (this is also mentioned in other answers and comments here).
    • e.g.: npx lerna add --scope=... packageA packageB
    • NOTE: This is an open issue in the lerna repo. Workarounds are discussed there as well.
like image 31
Domi Avatar answered Oct 27 '22 06:10

Domi