Closed adamnovak closed 2 years ago
You should be able to use both nvm
and n
simultaneously, in a general sense.
The auto-sourcing of nvm shouldn't cause any issue - you may need to nvm unalias default
, though, to prevent it auto-using a version and shadowing the "system" one n
installs.
As for the prefix, that's why you should be using nvm :-) that way you don't have to overwrite npm root -g
so as to avoid sudo.
nvm
is not self-contained in the fashion you want. If you want to use it at all, you can't use prefix
. There's really no way around that except perhaps setting the prefix in an NPM_CONFIG_PREFIX
env var (instead of .npmrc
), and then unsetting that env var in the shell you're using to work with this one project.
This is really an issue with that specific project hardcoding in a version manager - as much as I'm glad they chose nvm
, it'd be the same issue if they'd chosen anything else that you weren't already using. By them choosing to force a version manager, to develop it, you're simply forced to adjust.
It's not quite as forced as it could be; it's just specified to be used in the README, not in the actual Makefile.
I'll try doing my prefix as NPM_CONFIG_PREFIX
, which is easier to change around than editing the config file back and forth when I want to use or not use nvm.
I installed nvm by cloning the repo to ~/.nvm and adding the lines specified in the README to my bashrc.
I did this because I need to build a project (https://github.com/aws/amazon-genomics-cli) that has
nvm install
as one of its build steps, and uses a.nvmrc
file. I don't really want to use nvm to manage npm and nodejs in general for my user, beyond being able to follow the build steps for this project. I already use n to change node versions globally for my user. I'm probably going to have to take out the bashrc lines and move them to something I source just for the project, since nvm seems to want to replace n.For non-nvm-managed Node and NPM, I have
prefix
set in~/.npmrc
, so thatnpm install -g
can install things somewhere actually writable by me.nvm has decided to complain in every shell I open that there's a prefix set in my
~/.npmrc
. It prompts me to run:All that does is delete the prefix option from the file. I need to keep the prefix option around for when I'm not working on this particular project.
Operating system and version:
Ubuntu 20.04
nvm debug
output:nvm ls
output:How did you install
nvm
?I installed nvm by cloning the repo to ~/.nvm and adding the lines specified in the README to my bashrc.
I installed it after already having a working npm setup for installing packages with
-g
under my home directory, that I don't want to dismantle just so I can build a tool that usesnvm
in its build process.What steps did you perform?
Open a shell or run any nvm command.
What happened?
It complained about my ~/.npmrc file having the prefix directive, and prompted me to remove it.
What did you expect to happen?
nvm should be self-contained and not demand that I delete the prefix directive that I am using for other Node/npm installs.
Is there anything in any of your profile files that modifies the
PATH
?Yes, all sorts of stuff modifies my PATH. None of it seems relevant here though.