We have streamlined the npm password reset flow to simplify and secure the process of resetting lost passwords for you npm account.
For more information about creating a strong password, see "Creating a strong password".
We have streamlined the npm password reset flow to simplify and secure the process of resetting lost passwords for you npm account.
For more information about creating a strong password, see "Creating a strong password".
GitHub Security was recently notified about a caching issue affecting npm. This bug had been present since 2016 and sporadically caused npm maintainers to be re-invited upon removal from packages or organizations. Our Security team investigated potential instances of the issue and believe this bug only occurred if a user was removed, followed shortly by the addition of a different member. This bug affected npm-cli
version 6 and above, and was fixed in version 7+.
Out of an abundance of caution, we are recommending all npm users review the maintainers of their projects and organizations for any discrepancies that may be a result of this bug and remove any unexpected members. Please feel free to reach out to us with any additional questions or concerns through the following contact form: https://www.npmjs.com/support.
You can now view the content of a package with the updated code explorer directly on the npmjs.com portal. We have improved the reliability, performance and have now made this feature available for free. You no more need to download a package to view its content. With this feature, you can easily scrutinise packages to make sure it is safe for use in your application. The code explorer provides syntax highlighting for .js
, .ts
, .md
, .json
and other commonly used file types in npm packages. You can also view the content of any previous version of a package.
Start by exploring the npm package.
You can now create access tokens with limited scope using the new granular access tokens functionality in npm. With granular access tokens, you can:
Tokens with least privileges protects your npm packages from accidental or malicious misuse of your token. These tokens also allow you to manage your npm org and teams from a CI/CD pipeline. Granular access tokens are specifically built for automation and do not require 2FA. We recommend using granular access tokens with least privileges while you automate publishing and org management activities.
The npm CLI v9
is now generally available! As of today, running npm i -g npm
will install the latest
version (v9.1.1
). Details on the major breaking changes, features and bug fixes of v9
can be found in our last changelog post.
A huge shout out to all of the contributors who helped make this release possible and who continue to make npm
awesome.
Learn more about v9.1.1
in the release notes. You can also find references to previous releases in the project's CHANGELOG.md
.
Starting today, two-factor authentication (2FA) will be enforced for maintainers of all high-impact npm packages. A package is marked as a high impact package when they have more than 1 million weekly downloads or have more than 500 dependents. Maintainers of such packages will be notified 15 days in advance to enroll for 2FA.
To learn more about configuring 2FA, see Configuring two-factor authentication.
To learn more about 2FA in general, see About two-factor authentication.
For questions and comments, open a discussion in our feedback repository.
In July 2022 the public npm registry migrated away from the existing PGP signatures to a new ECDSA signatures for signature verification.
PGP based registry signatures will be deprecated on March 31st 2023. This means no new packages will be signed with PGP keys from this date onwards and the public key hosted on Keybase will expire.
Read more about registry signatures.
We have streamlined our account recovery flow to help us verify your identity in the instance you lose access to your two-factor authentication (2FA) device and get locked out of your npm account.
If you lose access to your 2FA device and your recovery codes, you can now sign in to your npm account using your username and password and then request an account recovery. You will be asked to fill the form as shown below. We recommend you provide as much information as possible when requesting an account recovery.
Read more about how you can recover your 2FA enabled accounts here.
For accounts with 2FA, linking your GitHub account and Twitter account in your profile settings will help verify your identity quicker.
Note: The new account recovery flow tries to gather and map information about your identity such that our support team can address your request sooner. Since there is a manual review in place, this recovery process will take few days to complete. We recommend our users generate and keep a copy of their recovery code to be used as the primary recovery option and avoid getting locked out of your account for a prolonged period of time.
The npm
CLI team has been working hard over the past few months and are happy to announce the release of the next major version – v9.0.0
You can start using npm
v9.0.0
today by running:
$ npm i -g npm@9
Our goal with this major release was to standardize appropriate defaults and clean up legacy configurations where possible. We believe the changes made lay the ground-work for future improvements to the default npm
experience long-term. Notably, Docker users should find this release to to be beneficial as we simplifie file permissions (ref. #5703 & #5704).
Although we have published v9.0.0
, we are not immediately setting this release to latest
in the npm registry or considering this “Generally Available.” Our team has been coordinating with the Node.js Release WG on a phased approach to making v9
the next major version of the CLI available to the widest audience; this means ensuring v9
can be safely backported to as many Node.js LTS versions as possible. With that in mind, we’ve put together a phased roll-out plan outlined below:
npm@9.0.0
was released & set to the next-9
dist-tag (previously used for pre-releases)v9.x
, addressing any feedback or unexpected issues arising from the breaking changes (outlined below)npm@9.x
is considered "non-breaking" for Node.js LTS we will codify a set of exit criteria in collaboration with the Release WGnpm@9.x
will be set to the latest
dist-tag (becoming the latest, maintained version of npm
)npm@9.x
in nodejs/node
's main
branch (exposing experimental/nightly users to this latest version)npm@9.x
in node@19
node@19
backport)
npm@9.x
in node@18
node
have been updated to: ^14.17.0 || ^16.13.0 || >=18.0.0
npm
will no longer attempt to modify ownership of files it createslogin
, adduser
, and auth-type
changes
sso
, saml
& legacy
have been consolidated into "legacy"
auth-type
defaults to "web"
login
and adduser
are now separate commands that send different data tonpm pack
now follows a strict order of operations when applying ignore rules. If a files
array is present in the package.json
, then rules in .gitignore
and .npmignore
files from the root will be ignored.HEAD
instead of master
as the default reftiming
and loglevel
changes
timing
has been removed as a value for --loglevel
--timing
will show timing information regardless of--loglevel
, except when --silent
--timing
file changes:
--timing
flag, npm
now writes timing data to alogs-dir
option and<CACHE>/_logs/
dir, instead of directly inside the<ID>-timing.json
file, with the<ID>
portion being the same as the debug log.metadata
, timers
, and unfinishedTimers
instead of everything beingnpm
now outputs some json errors on stdout. Previously npm
would output all json formatted errors on stderr, making it difficult to parse as the stderr stream usually has logs already written to it.--install-strategy
--global-style
, --global
now sets --install-strategy=shallow
--legacy-bundling
, now sets --install-strategy=nested
npm config set
will no longer accept deprecated or invalid config optionsinstall-links
config defaults to "true"
node-version
config has been removednpm-version
config has been removednpm access
subcommands have been renamednpm birthday
has been removednpm set-script
has been removednpm bin
has been removed (use npx
or npm exec
to execute binaries)a09e19d
#5696 new npm config fix
command (@nlf)3445da0
npm
timings are now written alongside debug log files (@lukekarrys)6ee5b32
query: now displays queryContext
in results (@nlf)314311c
#5550 separated login
/adduser
(@wraithgar)de2d33f
add --install-strategy=hoisted|nested|shallow
(#5709) (@fritzy)For more information about this release, check out the GitHub release notes.
We recently released the ability to use web based authentication for the npm login
and npm publish
commands with the --auth-type=web
flag. Now we are extending this feature to all the other commands that require authentication or OTP verification.
This feature is available from CLI version 8.19.1
You can now place a support request for an export of your npm data.
Once a request is placed, our support team will review it and initiate an export. You will get an email with a link to download the archive which is valid for 7 days. You must login to your account to download the archive.
Read more in our documentation
npm query
is a new top-level command as of npm v8.16.0 which accepts a Dependency Selector (as defined in the Dependency Selector Syntax Specification) & returns a filtered JSON Array/NodeList of dependencies from your project. We believe this capability has been a missing piece of the package management ecosystem; With its introduction we hope to unlock the potential for developers to self-serve in asking new, complex questions about their dependencies, their relationships & associative metadata.
For many JavaScript developers, the Dependency Selector Syntax will look very familiar as it is actually an adapted form of CSS. We leveraged this existing, known language & its operators to make disparate package information broadly accessible.
If I wanted to list all of my dependencies (similar to npm list --all
) I can run:
npm query "*"
If I wanted to find every version of react
& lodash
in my project I can run:
npm query "#react, #lodash"
If I wanted to find all react
versions not-defined as a peer dependency I can run:
npm query "#react:not(.peer)"
If I wanted to find all the dependencies in my project that used an MIT
license I'd change that query to be:
npm query "[license=MIT]"
If I wanted to find all the git dependencies in my project I can run:
npm query ":type(git)"
If I wanted to find out which of my transitive dependencies used a postinstall
script I could run:
npm query ":attr(scripts, [postinstall]):not(:root > *)"
We know many developers in the ecosystem will also want to leverage this new syntax themselves, so we've built it right into the programmatic brain of the CLI. Under the hood, we’ve added a new .querySelectorAll()
method to the existing Node
Class we use in the @npmcli/arborist
library. Tooling authors can now load up & query their dependencies just like we do.
// index.js
const Arborist = require('@npmcli/arborist')
const arb = new Arborist({})
arb.loadActual((tree) => {
// query all workspaces
const results = await tree.querySelectorAll('.workspace')
console.log(results)
})
You can learn more about the syntax & usage in our documentation here: https://docs.npmjs.org/cli/v8/using-npm/dependency-selectors
Looking ahead we’ve got work planned to add new pseudo states & selectors based on registry metadata that should unlock another host of capabilities aimed at auditing (examples include: :outdated
:deprecated
:vulnerable
:cve()
& :cwe()
). As documented in the original RFC proposal we will also consider supporting a query
flag or reading from stdin
to existing commands.
Enhanced Two-Factor Authentication (2FA) experience is now Generally Available. Previously, we had announced a set of improvements in our public beta. Further to this we have made the following new changes to streamline the CLI login experience.
--auth-type=web
flag.Read more about two-factor authentication
from our documentation.
The public npm registry is migrating away from the existing PGP signatures to ECDSA signatures that are more compact and can be verified without extra dependencies in the npm CLI.
Ensure the integrity of packages you download from the public npm registry, or any registry that supports signatures, by verifying the registry signatures of downloaded packages using the following npm CLI command:
npm audit signatures
The CLI will error if some packages have missing or invalid signatures. This could indicate that those packages might have been tampered with.
Read more about this feature from our documentation: about registry signatures.
Two-Factored Authentication (2FA) is now enforced for maintainers of the top-500 packages, by dependents, on the npm registry.
To learn more about configuring 2FA, see Configuring two-factor authentication.
To learn more about 2FA in general, see About two-factor authentication.
For questions and comments, open a discussion in our feedback repository.