Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News NPM 3 Beta Brings Good News for Windows Users

NPM 3 Beta Brings Good News for Windows Users

This item in japanese

The beta of npm 3.0 has been released, with an almost complete rewrite of its installer bringing good news for running Node.js on Windows.

Announcing the release, Rebecca Turner said the npm team were "delighted and proud" to be getting the 3.0 beta out, and that they were "looking forward to working with the npm user community to get it production-ready as quickly as possible."

Turner is the CLI programmer responsible for nearly all of the changes, and says the update took eight months of work.

One of the most significant changes to npm is the updates to dependencies. Flattended dependencies are expected to eliminate cases where too many dependencies would break the Windows file system, resulting in paths that were too long for Explorer or other standard tools to deal with.

Turner says:

Dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.

This update also means that installs are deduped "from the start", git deps are deduped, and even commands are "dedupe aware."

Talking to InfoQ, Turner says as a user she is most excited about automatically-deduped deps, which she says can "result in substantially smaller installations".

The behavior of other commands are also affected by the dependencies updates. With the update npm uninstall removes any dependencies of the module that have been specified as not required by any other module, where in the past this would remove the dependencies that happened to be installed under it. It should be noted that npm's own dependencies are also "flattened, deduped, and bundled," so npm 3.0 can't be packed or published by npm 2.0.

Other practical changes to the installer include improvements to how npm executes steps for packages. In previous versions, the installer would immediately start executing its sets of steps as soon as it decided to act on a package. With 3.0, the installer instead executes the steps at the same time for all packages -- now waiting for each stage to complete before moving on. For developers, this means that many race conditions are eliminated: making the code easier to reason about.

In a practical sense, Turner says the update means that things like the lifecycle scripts will be more predictable and less error-prone, and is also what allowed for easy implementation of other features like the new --dry-run flag. Turner says this lets developers see what it would do before taking any action, with detailed logs to show the full tree before and after the installer makes any changes.

Overall, Turner hopes that the npm 3.0 beta will result in fewer bugs and a more stable platform for developers.

The beta release comes with the expected caveat that npm 3.0 will remain in beta until the team are "confident that it's stable and have assessed the effect of the breaking changes on the community." Turner also points out that because this is a significant rewrite there will be bugs remaining, and that the beta should be used in "non-critical CI environments and for day-to-day use", not for "production maintenance or frontline continuous deployment."

For InfoQ readers keen to contribute to npm, there are a number of avenues: the usual pull requests, bug reports, and feature requests for both documentation and code changes are always appreciated by the npm at the issue tracker. Beyond direct contributions, the npm team are appreciate of educational tutorials and articles along the lines of "how I solved a problem and what modules I used" and will often include links to such articles in npm Weekly.

Rate this Article