LinuxCommandLibrary

npm-deprecate

Mark npm package versions as deprecated

TLDR

Deprecate a specific version of a package

$ npm deprecate [package_name]@[version] "[deprecation_message]"
copy

Deprecate a range of versions of a package
$ npm deprecate [package_name]@"<[version_range]" "[deprecation_message]"
copy

Un-deprecate a specific version of a package
$ npm deprecate [package_name]@[version] ""
copy

SYNOPSIS

npm deprecate [@]

PARAMETERS

<pkg>
    The name of the package to deprecate.

[@<version-range>]
    An optional version or version range to deprecate. If omitted, all versions are deprecated. Can use semver ranges (e.g., `1.x`, `^2.0.0`, `>3.0.0 <4.0.0`).

<message>
    The deprecation message to display when users try to install the deprecated version(s). This message should clearly explain why the version is deprecated and suggest alternative versions or actions.

DESCRIPTION

The `npm deprecate` command allows you to mark specific versions, or ranges of versions, of a package in the npm registry as deprecated. This is useful for indicating that a package version should no longer be used, often because it has security vulnerabilities, bugs, or is simply outdated.

When a user attempts to install a deprecated package version, npm will display a warning message during the installation process. This warning informs the user that the selected version is no longer recommended and suggests migrating to a newer, supported version. Deprecation messages are stored within the package metadata on the npm registry. They will be visible to anyone viewing the package on the npm website or using the npm CLI. You must be an authorized user of the package (typically the maintainer) to deprecate its versions. This command promotes responsible package maintenance and helps users avoid problematic versions. It contributes to a more secure and reliable ecosystem.

CAVEATS

Requires appropriate permissions on the npm registry for the package being deprecated.

UNDEPRECATING A PACKAGE

To undeprecate a version, you can deprecate it with an empty message. For example: `npm deprecate my-package@1.0.0 ""` removes the deprecation message from version 1.0.0. To undeprecate all versions, use `npm deprecate my-package@ '*' ""`

SEMVER RANGES

Be precise with your version ranges. Vague or overly broad ranges can inadvertently deprecate versions you didn't intend to deprecate. Use semver syntax (e.g., `^2.0.0`, `~1.2.0`) to target specific versions or ranges within your package.

SEE ALSO

Copied to clipboard