[RRFC] Cleaning up the prefix config story
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 777
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
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
globalDirinternal configuration value:
globalDir=${globalPrefix}/lib/node_modules,globalDiris the location to
thenode_modulesfolder 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the current prefix handling in @npmcli/config, especially lib/index.js around the referenced line, and review related issue 3088 plus the Windows npmrc link. Done means turning the documented local/global prefix, global package directory, and Windows default concerns into a concrete RFC proposal with agreed solutions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100