BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Npm 5.0 Boosts Common Sense Performance

Npm 5.0 Boosts Common Sense Performance

Bookmarks

Npm, Inc. has released version 5.0 of their npm package manager, capping off years of planning, months of coding, and boosting performance to be more in-line with the competition.

In a blog post announcing the release, npm says the new package manager is "a pretty big step forward, significantly improving its performance in almost all common situations". This release is major in not just version number, but in features and breaking changes.

Some of the biggest changes are to the performance and behavior of the cache, which was rewritten. Offline behavior, for example, has been changed; npm will now use the cache if the machine is offline instead of repeatedly trying to access the network. Developers can also set options such as --prefer-offline and --prefer-online to customize how their cache is used.

Because of this major rewrite, all existing caches are invalid and developers will need to re-download packages, so be sure to be on a fast connection when upgrading.

There are also many new features, and one of the most significant is that --save is now the default behavior. When a package is installed, saving a package to the package.json file required developers to issue the command:

npm install  --save

Despite developers almost always intending this behavior, they always had to opt-in explicitly. In 5.0, omitting the flag will save the package to package.json. On the flip side, if the developer doesn't want to save the package, the --no-save flag is now required.

Some in the community have credited yarn, the up-and-coming alternative package manager with lighting a fire under npm and motivating them to improve their performance. Hacker News user chrisweekly wrote, "Thank you, yarn, for helping the community see the naked emperor. Deterministic builds by default are such an obvious (in retrospect) core requirement."

Npm CEO Isaac Schlueter says the changes have been a long time coming and are not a response to yarn:

Everything in npm 5 was literally planned years in advance. When we have this many people depending on a thing, we have to be careful about how we make drastic changes. Yarn was a strong signal from the community that we were on the right track, but it only seems like a "catalyst" when seen from the outside.

Regardless of who thought of it first, developers win with access to better, faster tools. The full release notes are available on GitHub.

Rate this Article

Adoption
Style

BT