rfcs
rfcs copied to clipboard
[RRFC] Cleaning up the prefix config story
Intro
The prefix
config option does not provide a great user experience and is a
source of many (mostly invalid) bug reports from confused users. These users
have very legitimate reasons to be confused, given that prefix
encompasses
many different concepts and affects many different commands and overall
npm cli functionality.
Documenting current known pain points & problems
Local prefix vs Global prefix
Currently prefix
conflates two essential concepts: localPrefix
and
globalPrefix
, these are currently differentiated only in the internal cli
implementation and the only way for users to change these values is by using
the prefix
config option along with global
.
Global prefix usage
globalPrefix
itself is a config that has many shared responsabilities and its
value affects different commands:
- It's used to construct the
globalDir
internal configuration value:globalDir=${globalPrefix}/lib/node_modules
,globalDir
is the location to thenode_modules
folder that holds all the globally installed packages.
Windows sane defaults
Currently the default value for globalPrefix
in windows defaults to the
folder location of the current executing node instance, which by default is
usually: C:\Program Files\nodejs
, this results in EPERM
errors when trying
to reify anything to the global package space if not running in admin mode.
This problem is avoided today by most of our windows user base due to nodejs
itself bundling a builtin config file that tweaks the prefix value to point to:
%APPDATA%\npm
Note: Should we bless that location and make it the new default value in
@npmcli/config
instead ?
Related: https://github.com/npm/cli/issues/3088
Moving forward
This is mostly a wip draft that aims to highlight these problems, feel free to maybe connect any missing related problems that I might have forgotten to list here and hopefully this can lead to an actual RFC that proposes solutions to these problems.