Skip to content

[RRFC] Include a globallink install strategy #817

Open

Description

@TheBrenny

Motivation ("The Why")

There's no doubt that NPM is the butt of a lot of memes relating to how heavy the local node_modules folder can get. Especially on big projects, and when working on multiple big projects over time, the duplication of the same packages across different project spaces can cause a significant impact on hard drive space. A tool already exists to address this issues: PNPM. However, PNPM is not a 1-for-1 replacement - there are some quirks with the commands, and while for the most part it works, these nuances can get in the way of efficient package management, including when sharing code among developers (especially in the Open Source community).

A globallink install strategy should be included to address this and would work similar to how the linked strategy works now. However, instead of the packages being saved in ./node_modules/.store, they would be saved in /path/to/npm/global/node_modules/.store.

This will also cause an update to the clean-install command where the packages (and exact dependencies) for a project are deleted from the global store and re-installed.

Of course, this install strategy can be overridden by specifying a different type at the command line or local config.

How

Current Behaviour

The hoisting of packages to the root of the node modules folder helps to deduplicate packages across the project. However, this is only localised to the project. As an example, I work on many web apps that all use SvelteKit and I need to download and store the entire SvelteKit package every time for each project (36MB). Add on the extra frameworks that I use, and that number starts to add up pretty quickly to a couple hundred megabytes.

Desired Behaviour

By specifying the install-strategy as globallink all the packages would be installed into a global store. npm would resolve the package requirements of an install command, determine that a package exists within the store which meets the version criteria and links to it instead of downloading it again. If no package in the store meets the criteria, one is simply downloaded.

I might be oversimplifying the complexity, but the implementation could be an increase in capability of the linked install strategy, in that the store that it points to is the global store, rather than the local one.

Activity

  1. stefanobaghino commented on Sep 8, 2025

    @stefanobaghino

    I find this to be a really interesting improvement idea. I'm under the impression that pnpm is quite popular (as the latest State of JS seems to confirm) and particularly on the grounds of its approach leading to faster response times.

    An improvement like this could make a difference for all npm users. I would love to hear the npm CLI team's opinion on this. 🙂

  2. ljharb commented on Sep 8, 2025

    @ljharb
    Contributor

    This is already what "isolated layout" mode does, I believe.

  3. stefanobaghino commented on Sep 9, 2025

    @stefanobaghino

    This is already what "isolated layout" mode does, I believe.

    @ljharb IIUC isolated mode (referred to in the original post by how it's enabled, with --install-strategy=linked) enables to have packages in a monorepo to share unhoisted packages and link from the local shared store to the various package. Unless I misunderstood, I believe @TheBrenny's RRFC would be a for a mode where there all packages in a system are installed in central location and linked from there, just like pnpm does. Is my understanding correct? 🙂

  4. ljharb commented on Sep 9, 2025

    @ljharb
    Contributor

    ah, thanks for clarifying.

  5. TheBrenny commented on Nov 29, 2025

    @TheBrenny
    Author

    I'm now starting to realise that an issue RRFC won't make movement? Am I correct in thinking that I need to submit a PR with the actual RFC.md as per the repo instructions?

  6. ljharb commented on Nov 30, 2025

    @ljharb
    Contributor

    the RFC process has been suspended for years and unsolicited feature addition PRs rarely get traction.

  7. TheBrenny commented on Nov 30, 2025

    @TheBrenny
    Author

    What's the process to feature request for npm then, though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions