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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
nvmmakes use of$PREFIXto maintain multiplenode/npmsystems, however Termux (a terminal emulator for Android) also uses$PREFIXin their environment, so Termux andnvmcollide. Deprecating the variable on Termux shall be possible, but a lot of third party scripts are out there that use$PREFIXto work within Termux.The idea is to patch
npm(andnode) to look for$NODE_PREFIXor$NPM_PREFIXand then falling back to$PREFIX. But: There also need to be a way to disable the fallback legacy$PREFIXso that it can be ignored, if it's set by something else, so it won't disrupt the logic ofnpm. This waynvmcouldsetwork with$NODE_PREFIXor$NPM_PREFIXinstead of$PREFIXand Termux could safely continue to use$PREFIX, things wouldn't break.Ideally,
npmgets patched and released with this change for all versions that are shipped withnodein 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