Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: lerna remove #1886

Closed
tanhauhau opened this issue Jan 23, 2019 · 36 comments
Closed

Feature: lerna remove #1886

tanhauhau opened this issue Jan 23, 2019 · 36 comments
Labels
scope: package management Issues with the bootstrap/add/link commands that relate to package management

Comments

@tanhauhau
Copy link
Contributor

Removes dependency from packages, the inverse of @lerna/add

Currently there's no way to remove a dependency from a lerna package,
the closest way we can do is to manually remove from package.json, lerna clean --yes --scope=xxx + lerna bootstrap --scope=xxx.

This command provides the remove dependency feature. Just like npm uninstall or yarn remove.

@KaboomFox
Copy link

👍

1 similar comment
@einsqing
Copy link

👍

@garrettmaring
Copy link

What does the --yes flag do?

One can also run $ lerna exec 'yarn remove foo' --scope=xxx to remove it.

@a1300
Copy link

a1300 commented Sep 15, 2019

The following workaround worked for me:

  1. Manually remove dependencies from @org-name/package-name/package.json
  2. Run:
$ lerna bootstrap --scope @org-name/package-name --no-ci --force-local

@AlanSl
Copy link

AlanSl commented Oct 29, 2019

If you're using yarn workspaces with Lerna (generally a good idea, avoids dependency duplication related problems), you can do something equivalent to lerna remove --scope="some-package" some-dep quite simply:

yarn workspace some-package remove some-dep

...but it'd be simpler still to just be able to use lerna alone and mirror lerna add.

@mikhailrojo
Copy link

please add

lerna remove package --scope=...

@diminutivesloop
Copy link

What's the status of this feature? This issue is already over a year old.

@danawoodman
Copy link

@evocateur is this something you plan to add? If not, maybe some documentation could be added as to the preferred method of removing packages?

@chaddjohnson
Copy link

I am very surprised to find that there is an add but not a remove...

@EricRabil
Copy link

EricRabil commented May 10, 2020

Typed add instead of create... added a random package to all of my packages that I must now manually remove as lerna exec 'yarn remove foo' --scope=xxx spits out unrelated errors due to my setup. This needs a remove counterpart.

@a1300
Copy link

a1300 commented Jun 28, 2020

@mesqueeb last commit was 19 days ago. It seems to be still maintained.

@geeeger
Copy link

geeeger commented Aug 13, 2020

i need it, too.

@tkforce
Copy link

tkforce commented Sep 17, 2020

Seems like a reasonable feature request +1

@lfre
Copy link

lfre commented Oct 29, 2020

Apologies if this is already mentioned in another issue. I'm putting this out there for the next person running into the same issue I just did.

I noticed lerna add has an issue where the local package is removed from the lock files (package-lock.json, yarn.lock).
Re-adding or bootstrapping won't have effect, because node_modules is still there.

This will cause lerna exec "[npm uninstall|yarn remove] dep" --scope=xxx to error out if the package/version is not found in the registry. Most concerning is if you have a published package and/or you have a local package name that also exists in the public registry, it'd choose that one and add it to lock instead of the local reference.

I created a repo to reproduce the issue: https://github.com/lfre/lerna-add-remove-issue.

TLDR: The solution is to manually delete the lock file e.g: package-json.lock in question before running the exec command to remove the dependency.

Even though the issue is with lerna add, it's worth to be mentioned here because I think this is something that a lerna remove command can check/verify.

@thiagodelgado111
Copy link

Hey folks, is there any way someone not lerna-savvy can help doing a PR for this one?

@hinell
Copy link

hinell commented Nov 6, 2020

@thiagodelgado111 There is one and it's already closed by maintainer: #1887
He proposed to move to other tools like npm for such command.

@mesqueeb
Copy link

mesqueeb commented Nov 6, 2020

#1887 (comment)

I don't really see this going forward anymore, sorry. I appreciate all the effort spent on this PR, but modern monorepos should be using package managers with proper capabilities to deal with this sort of thing (pnpm recursive, npm v7, yarn i guess).

Given the minimal frequency of use for this sort of command, the maintenance burden far outweighs the benefit of inclusion in the core. Perfect opportunity for a third-party utility.

I think this can be closed as "won't fix"

@davidmurdoch
Copy link

If lerna remove shouldn't be a lerna feature, then shouldn't lerna add be removed from lerna?

@janoist1
Copy link

Is a joke, right? 👏

@slyadams
Copy link

The problem is that you can't just use npm if you have dependencies between your own packages.

@joshuarobs
Copy link

Any update on this?

@ddzy
Copy link

ddzy commented Apr 2, 2021

Any progress?

@lili21
Copy link

lili21 commented Apr 26, 2021

we need this

@liho00
Copy link

liho00 commented May 27, 2021

help us lerna! WE NEED lerna remove since 2019

@yahiarefaiea
Copy link

I need this, too!

@yahiarefaiea
Copy link

lerna exec -- 'npm rm lodash' worked for me.. despite how slow it was.. but it worked.
Still wondering if there can be a better way...

@Tate-Young
Copy link

我们需要 lerna remove
必要です lerna remove
우리는 필요하다 lerna remove
we need lerna remove
nous avons besoin lerna remove
wir brauchen lerna remove

@hinell
Copy link

hinell commented Jul 8, 2021

There ain't gonna be any remove command. Move on.

@mrdulin
Copy link

mrdulin commented Jul 16, 2021

It seems lerna remove is equivalent to:

  1. Remove dependency from the package.json of a package.
  2. Run npx lerna bootstrap, it will remove dependency information from yarn.lock or package-lock.json.

@shchypylov
Copy link

@mrdulin It does not.

@laurent22
Copy link

laurent22 commented Nov 27, 2021

29 changed files and thousands of lines of code just to add this command seems a bit crazy. I can see why it wasn't added although it's obviously essential (no sensible tool has an "add" command without a matching "remove" one), and the 257 upvotes on this issue speak for themselves.

Anyway Lerna is pretty much discontinued now so it's unfortunately time to migrate to other tools.

@tvdaredevil
Copy link

Still waiting for this feature!!!

@chaddjohnson
Copy link

chaddjohnson commented Oct 12, 2022

Honestly I don’t see the big deal. Just run

lerna exec 'yarn remove package-name' --scope=package

@jameshhood
Copy link

Honestly I don’t see the big deal. Just run

lerna exec 'yarn remove package-name' --scope=package

At that point, why not use this to add something as well? At least there are a couple of workarounds but I would think as a common practice, where there is an add, there is a remove. Where there is a create, there needs to be an update, and delete. It's just common practice.

I've been using lerna now for a week and this is one of the first issues I've ran into and of course I come here to find solutions. It is a bit alarming to see issues like this open for so long and desired by so many people.

@sunnynudt
Copy link

I need the feature lerna remove xx --scope=xxx😭

@JamesHenry
Copy link
Member

Hi Folks 👋

Lerna is the original monorepo/workspace tool in the JavaScript ecosystem. When it was created in 2015/2016 the ecosystem looked totally different, and there were no built in capabilities to handle working with multiple packages in a single repository (a "workspace"). Commands like lerna bootstrap, lerna add and lerna link were all a critical part of the lerna project, because there were no other options.

However, now that we find ourselves in late 2022, the fact is that - for many years now - the package managers we know and love (npm, yarn and pnpm) all fully support that concept of workspaces as a first-class use-case.

They have battle tested implementations covering adding, removing and linking local packages, and combining them with third party dependencies in a natural way.

This is the reason why, for the past several years of his tenure as lead maintainer of Lerna @evocateur has been encouraging folks to strongly reconsider their use of the legacy package management commands in lerna, and instead leverage their package manager of choice to do what it does best.

We knew about this context from afar, but as new stewards of the project we did not want to jump straight in and start removing capabilities without first taking the time to get familiar with the reality up close. Now that we have been actively maintaining the project for half a year, we are in full agreement with Daniel and others that the legacy package management commands in lerna need to be retired.

By removing these legacy pieces which have better alternatives natively in package managers, we and the rest of the lerna community will be freed up to concentrate our efforts on things which are uniquely valuable about lerna (such as, but not limited to, versioning and publishing), and making them the best they can be!

From version 7, therefore, we will no longer ship the legacy package management commands (such as lerna bootstrap, lerna add and lerna link) by default with lerna, and instead make them available as an add-on via a separate package (name TBD).

This new package can be thought of as being in maintenance mode only - no new features will be considered for legacy package management concerns (such as lerna bootstrap, lerna add and lerna link), and we will only look to merge critical patches and security updates.

We of course want to make sure that folks who are perhaps less aware of the modern capabilities of their package manager are not left confused by this change, so we will be building out comprehensive migration guides on https://lerna.js.org/ to help them transition their thinking from a legacy lerna command to its equivalent for npm, yarn or pnpm.

If you have any specific concerns please kindly join in on the Lerna v7 Roadmap discussion and provide as much context as possible: #3410

Many thanks 🙏

@JamesHenry JamesHenry closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2022
@lerna lerna locked and limited conversation to collaborators Nov 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope: package management Issues with the bootstrap/add/link commands that relate to package management
Projects
None yet
Development

No branches or pull requests