Deprecate environment variable $PREFIX
and start looking at $NODE_PREFIX
or $NPM_PREFIX
to reduce collision potential
#128434
Unanswered
martin-braun
asked this question in
npm
Replies: 0 comments 3 replies
-
To be clear, nvm doesn't set PREFIX, it merely checks it - because if it's set, then npm will look outside of nvm's node directory for global modules. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Since npm already looks at NPM_CONFIG_PREFIX, for a long time now, it would be a pretty small breaking change to just drop PREFIX entirely as an env var (even if it was kept in config as “prefix”). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
nvm
makes use of$PREFIX
to maintain multiplenode
/npm
systems, however Termux (a terminal emulator for Android) also uses$PREFIX
in their environment, so Termux andnvm
collide. Deprecating the variable on Termux shall be possible, but a lot of third party scripts are out there that use$PREFIX
to work within Termux.The idea is to patch
npm
(andnode
) to look for$NODE_PREFIX
or$NPM_PREFIX
and then falling back to$PREFIX
. But: There also need to be a way to disable the fallback legacy$PREFIX
so that it can be ignored, if it's set by something else, so it won't disrupt the logic ofnpm
. This waynvm
couldsetwork with$NODE_PREFIX
or$NPM_PREFIX
instead of$PREFIX
and Termux could safely continue to use$PREFIX
, things wouldn't break.Ideally,
npm
gets patched and released with this change for all versions that are shipped withnode
in the LTS channel as far back as possible. It would be nice to see this happen for npm 9, 8 and 6.Related issues:
cc @ljharb @agnostic-apollo @goodevilgenius @GameKyuubi
Beta Was this translation helpful? Give feedback.
All reactions