Skip to content

[BUG] npm creates its cache directory in my $HOME #1451

@WhyNotHugo

Description

@WhyNotHugo

What / Why

npm keeps creating its cache directory in my $HOME. I keep very few directories in my $HOME to keep things findable, and its very annoying when apps start littering stuff there.

When

Any time I run things like npm install blah.

Where

$ uname -srmo
Linux 5.7.2-arch1-1 x86_64 GNU/Linux

How

Current Behavior

A directory is creted in $HOME and cache data stored in there.

Steps to Reproduce

  1. Run rm -rf .cache to delete your existing cache.
  2. Navigate to a directory with an existing package.json.
  3. Run npm install.

Expected Behavior

The cache directory should be in $XDG_CACHE_HOME on Linux. Specifically, it should be $XDG_CACHE_HOME/npm. $XDG_CACHE_HOME should default to .cache if undefined.

I believe on macOS there's a different spec for default locations, and things like cache are stored in a different place. I don't know the name of the spec so can't easily link in here.

Who

  • n/a

References

XDG Base Directory Specification

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions