From d10c7d68d23f42fb2c607f42375ff1a76c226717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Zi=C3=B3=C5=82kowski?= Date: Fri, 18 Oct 2024 15:52:18 +0200 Subject: [PATCH] Update the documentation to provide better instruction for uninstalling npm dependencies from packages --- packages/README.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/README.md b/packages/README.md index 76c310bda89e0..27efdf2d43ad5 100644 --- a/packages/README.md +++ b/packages/README.md @@ -74,27 +74,24 @@ _Example:_ npm install change-case -w packages/a11y ``` -This command adds the latest version of `change-case` as a dependency to the `@wordpress/a11y` package, which is located in `packages/a11y` folder. +This command adds the `change-case` as a dependency to the `@wordpress/a11y` package, which is located in `packages/a11y` folder. If there was the same dependency installed then the version specified in the `package-lock.json` file is going to be reused. If you want to enforce a different version, you can do so by adding the `@` suffix to the package name. + +_Example:_ + +```bash +npm install change-case@latest -w packages/a11y +``` #### Removing Existing Dependencies -Removing a dependency from one of the WordPress packages requires some manual work. You need to remove the line in the corresponding `dependencies` section of the `package.json` file. +Removing a dependency from one of the WordPress packages is similar to installation. You need to run a command like the following from the root of the project. _Example:_ -```diff -+++ b/packages/scripts/package.json -@@ -43,7 +43,6 @@ - "check-node-version": "^4.1.0", - "cross-spawn": "^5.1.0", - "eslint": "^7.1.0", -- "jest": "^29.6.2", - "minimist": "^1.2.0", - "npm-package-json-lint": "^6.4.0", +```bash +npm uninstall change-case -w packages/a11y ``` -Next, you need to run `npm install` in the root of the project to ensure that `package-lock.json` file gets properly regenerated. - #### Updating Existing Dependencies This is the most confusing part of working with [monorepo] which causes a lot of hassles for contributors. The most successful strategy so far is to do the following: