Paul Krill
Editor at Large

NPM 5 reworks the cache for speed, but could break existing apps

news
May 30, 20172 mins

Other changes target better fault tolerance, garbage collection, and auto-saving

JavaScript code
Credit: Iwan Gabovitch

NPM, the popular JavaScript package manager, is being upgraded for better performance.

Expected to be released tomorrow, NPM Version 5.0 is two to six times faster than NPM 4, said Kat Marchan, a member of the NPM team. Other improvements include better defaults, simplified options, and better error messages.

NPM’s cache has been rewritten for speed. It also is fault-tolerant and supports concurrent access. Corrupted cache entries are automatically removed and refetched. Also, an NPM cache verify command performs garbage collection to reduce disk usage and provide integrity verification.

For reliability, NPM Version 5.0 offers better disk and network fault tolerance, an automatic offline mode, and automatic corruption recovery. New installer features include a standardized lock file for cross-package manager compatibility with package-lock.json as well as a new format and semantics for shrinkwrap.

Also, all installs are saved by default; the –save function is no longer needed. The NPM developers also said NPM no longer “blasts” the screen with an entire installed tree. “Instead, you’ll see a summary report of the install that is much kinder on your shell real estate.”

Meanwhile, project-level preinstall scripts now run first and can modify node_modules before the command line reading it. Version 5.0 also adds scripts for prepack and postpack.

NPM 5.0’s registry includes reduced data transfer when fetching package metadata, and adds support for SHA512 integrity hashes.

NPM 5.0 does break prior code, because existing NPM caches are no longer used and the cache commands have been rewritten. Users will have to re-download any cached package.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author