Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You have $NVM_DIR set to "/root/.nvm", but that directory does not exist. Check your profile files and environment

I'm trying to reinstall nvm (as a new user) after uninstalling it (as root) but clearly it didn't work. Please tell me how to fix this.

user@site-beta:~/htdocs$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13527  100 13527    0     0   105k      0 --:--:-- --:--:-- --:--:--  105k
You have $NVM_DIR set to "/root/.nvm", but that directory does not exist. Check your profile files and environment.

Edit: my advice is to give up on NVM and just install node normally, because clearly NVM isnt making it any easier.

like image 795
stackers Avatar asked Oct 20 '25 20:10

stackers


2 Answers

This usually happens when there was nvm already present under a different user profile on the same computer. Here's a simple set of steps that can help you resolve. Assuming you have access/rights on your computer to modify paths/directories and default variables.

  1. (make sure to replace 'USERNAME' above with your user profile/userid on the computer)
export NVM_DIR="/home/USERNAME/.nvm"
  1. Install nvm again:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
  1. Refresh the shell file:
source ~/.nvm/nvm.sh
  1. Ensure nvm has been installed. If it isn't, try to kill the terminal once and open a new terminal and try nvm -v again:
nvm -v
like image 171
vineeth agarwal Avatar answered Oct 23 '25 14:10

vineeth agarwal


What worked for me was editing /root/.profile and changing the path of the NVM_DIR as root, change that line to this:

export NVM_DIR="/home/<USERNAME>/.nvm"

replace USERNAME with the account you would like to run the script with, then run

source /root/.profile

After that switch to the desired user account using su command:

su <USERNAME>

And finally run the nvm install script one more time:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
like image 39
elijahbee Avatar answered Oct 23 '25 14:10

elijahbee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!