deprecate-totp-2fa
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: Deprecating and undeprecating packages or package versions |
| 3 | --- |
| 4 | |
| 5 | import shared from '~/shared.js' |
| 6 | |
| 7 | If you no longer wish to maintain a package, or if you would like to encourage users to update to a new or different version, you can [deprecate][deprecate-cli] it. Deprecating a package or version will print a message to the terminal when a user installs it. |
| 8 | |
| 9 | A deprecation warning or message can say anything. You may wish to include a message encouraging users to update to a specific version, or an alternate, supported package. |
| 10 | |
| 11 | <Note> |
| 12 | |
| 13 | **Note:** We strongly recommend deprecating packages or package versions instead of [unpublishing](/unpublishing-packages-from-the-registry) them, because unpublishing removes a package from the registry entirely, meaning anyone who relied on it will no longer be able to use it, with no warning. |
| 14 | |
| 15 | </Note> |
| 16 | |
| 17 | ## Deprecating an entire package |
| 18 | |
| 19 | Deprecating an entire package will remove it from search results on the npm website and a deprecation message will also be displayed on the package page. |
| 20 | |
| 21 | <Screenshot src="/packages-and-modules/updating-and-managing-your-published-packages/deprecate-package.png" alt="Screenshot of package deprecation" /> |
| 22 | |
| 23 | Deprecating a package is an alternative to deleting a package if your package does not meet the [unpublishing requirements](/policies/unpublish). |
| 24 | |
| 25 | ### Using the website |
| 26 | |
| 27 | 1. <>{shared['user-login'].text}</> |
| 28 | |
| 29 | <>{shared['user-login'].image}</> |
| 30 | |
| 31 | 2. Navigate to the package page for the package you want to deprecate, replacing `<your-package-name>` with the name of your package: `https://www.npmjs.com/package/<your-package-name>`. |
| 32 | |
| 33 | 3. Click **Settings**. |
| 34 | |
| 35 | <Screenshot src="/packages-and-modules/securing-your-code/2fa-package-admin.png" alt="Screenshot showing the settings tab on a package page" /> |
| 36 | |
| 37 | 4. Under "deprecate package", click <strong>Deprecate package</strong>. |
| 38 | |
| 39 | <Screenshot src="/packages-and-modules/deleting-deprecating/deprecate-package-settings.png" alt="Screenshot showing the deprecate package button" /> |
| 40 | |
| 41 | 5. If you are sure that you want to continue, enter your package name and click <strong>Deprecate package</strong>. |
| 42 | |
| 43 | <Screenshot src="/packages-and-modules/deleting-deprecating/deprecate-package-confirm.png" alt="Screenshot showing the deprecate package confirmation" /> |
| 44 | |
| 45 | ### Using the command line |
| 46 | |
| 47 | To deprecate an entire package, run the following command, replacing `<package-name>` with the name of your package, and `"<message>"` with your deprecation message: |
| 48 | |
| 49 | ``` |
| 50 | npm deprecate <package-name> "<message>" |
| 51 | ``` |
| 52 | |
| 53 | If you have enabled [two-factor authentication][two-factor-auth], add a one-time password to the command, `--otp=123456` (where _123456_ is the code from your authenticator app). |
| 54 | |
| 55 | ## Deprecating a single version of a package |
| 56 | |
| 57 | When you deprecate a version of a package, a red message will be displayed on that version's package page, similar to deprecating an entire package. |
| 58 | |
| 59 | <Screenshot src="/packages-and-modules/updating-and-managing-your-published-packages/deprecate-version.png" alt="Screenshot of package deprecation for a particular version" /> |
| 60 | |
| 61 | ### Using the command line |
| 62 | |
| 63 | To deprecate a package version, run the following command, replacing `<package-name>` with the name of your package, `<version>` with your version number, and `"<message>"` with your deprecation message: |
| 64 | |
| 65 | ``` |
| 66 | npm deprecate <package-name>@<version> "<message>" |
| 67 | ``` |
| 68 | |
| 69 | The CLI will also accept version ranges for `<version>`. |
| 70 | |
| 71 | If you have two-factor auth, add a one-time password to the command, `--otp=123456` (where _123456_ is the code from your authenticator). |
| 72 | |
| 73 | ## Undeprecating a package or version |
| 74 | |
| 75 | To undeprecate a package, replace `"<message>"` with `""` (an empty string) in one of the above commands. |
| 76 | |
| 77 | For example, to undeprecate an entire package, run the following command, replacing `<package-name>` with the name of your package, and `<version>` with your version number: |
| 78 | |
| 79 | ``` |
| 80 | npm deprecate <package-name> "" |
| 81 | ``` |
| 82 | |
| 83 | Or to undeprecate only a single package version, run the following command, replacing `<package-name>` with the name of your package, and `<version>` with your version number: |
| 84 | |
| 85 | ``` |
| 86 | npm deprecate <package-name>@<version> "" |
| 87 | ``` |
| 88 | |
| 89 | If you have two-factor auth, add a one-time password to the command, `--otp=123456` (where _123456_ is the code from your authenticator). |
| 90 | |
| 91 | ## Transferring a deprecated package to npm |
| 92 | |
| 93 | If you are no longer maintaining a package, but other users depend on it, and you'd like to remove it from your user profile, you can transfer it to the [`@npm`][npm-account] user account, which is owned by the npm registry. |
| 94 | |
| 95 | <Note> |
| 96 | |
| 97 | **Note:** Once you transfer a package to the npm account, you will no longer be able to update it. |
| 98 | |
| 99 | </Note> |
| 100 | |
| 101 | To transfer a package to the npm user account, run the following two commands in order, replacing `<user>` with your npm user name, and `<package-name>` with the package you want to transfer: |
| 102 | |
| 103 | ``` |
| 104 | npm owner add npm <package-name> |
| 105 | npm owner rm <user> <package-name> |
| 106 | ``` |
| 107 | |
| 108 | If you have two-factor auth, add a one-time password to the command, `--otp=123456` (where _123456_ is the code from your authenticator). |
| 109 | |
| 110 | [deprecate-cli]: /cli/deprecate |
| 111 | [two-factor-auth]: about-two-factor-authentication |
| 112 | [npm-account]: https://www.npmjs.com/~npm |