21

I have a lerna setup with n packages located under packages/. Let us take an example where one of the packages uses express where the others do not.

How can I remove express from this package in a lerna-aware manner so the root package.json is updated?

I can add packages with lerna add --scope but it seems there is no corresponding remove functionality.

3 Answers 3

17
  1. Remove package from package.json
  2. Remove node_modules folder: rm -rf packages/{package_name}/node_modules
  3. Run lerna bootstrap

Without step 2 the package still exists in the package-lock.json NPM lock file.

1
  • 1
    This generated the package-lock.json updates that I wanted. This should be the accepted answer.
    – Satheesh
    Jun 20 at 10:31
13

Just remove the packages from your package.json

then run

$lerna bootstrap

1
  • 8
    This does not remove entries from package-lock.json unfortunately Oct 23, 2020 at 22:17
1

If you want to be sure that lerna bootstrap only updates the specific package-lock.json in @org-name/package-name/ and not other package-lock.json files, do:

  1. Manually remove dependencies from @org-name/package-name/package.json
  2. Remove the whole node_modules directory for this one package
rm -rf packages/package-name/node_modules
  1. Now bootstrap only this one package.
lerna bootstrap --scope @org-name/package-name --no-ci --force-local

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.