corepack icon indicating copy to clipboard operation
corepack copied to clipboard

Follow XDG Specification

Open shubham-cpp opened this issue 3 years ago • 5 comments

XDG Base Directory

By default, corepack creates folder on $HOME/.node/corepack. This should not be the default, but rather a fallback. Default location should be something like $XDG_CACHE_HOME/node/corepack or $HOME/.cache/node/corepack respecting the xdg specifications

shubham-cpp avatar Jul 13 '22 02:07 shubham-cpp

Note that the XDG specification uses "should" liberally, and "must" only rarely, so there's very little the XDG specification actually requires things to do in order to be compliant.

ljharb avatar Jul 13 '22 03:07 ljharb

Agreed, but since npm, pnpm and yarn,nvm, ect also provide options for xdg specs, then why not provide an option for corepack as well. People who might want to opt in to xdg specs can use that(like environment variable)

shubham-cpp avatar Jul 13 '22 04:07 shubham-cpp

Is it something you'd like to open a PR for?

aduh95 avatar Jul 14 '22 09:07 aduh95

Need to look into this

shubham-cpp avatar Jul 17 '22 17:07 shubham-cpp

came here to open this exact issue. I have XDG user dirs configured and

prefix=${XDG_DATA_HOME}/node
cache=${XDG_CACHE_HOME}/npm
init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js

in my npmrc (location configured via $NPM_CONFIG_USERCONFIG, which is fine) and now corepack and cacache are the two things ignoring this (yarn at least mostly follows XDG dirs) and constantly recreating the ~/.npm and ~/.node directories I'm trying to avoid having to a completely clean setup. I opened a ticket for cacache already ( https://github.com/npm/cacache/issues/119 ) and it'd be great if corepack could also use the $XDG_DATA_HOME variable if available.

Mitsunee avatar Jul 23 '22 09:07 Mitsunee

Big thank you to all the guys that worked on this. Open source community at its best again.

shubham-cpp avatar Aug 31 '22 04:08 shubham-cpp