Reputation: 6242
I want to use an older version of Node.js
in my application, and for that I have attempted to use nvm
so that I can change the version accordingly.
Now I have three versions of Node.js
and want to switch on specific version
nvm use [selected version]
It is successfully executed but the version is not updated
Example of use:
Upvotes: 0
Views: 6210
Reputation: 1
Since nvm alias default 6.11.2
is already set correctly but the terminal still defaults to 8.9.4
, the issue might be with how your shell loads nvm
. Follow these steps to fix it:
Check if nvm
is properly sourced in your shell config file (.bashrc
, .bash_profile
, or .zshrc
).
.bashrc
or .bash_profile
)Open your .bashrc
file:
nano ~/.bashrc
Ensure these lines exist at the bottom:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm use default
Save and exit (Ctrl + X
, then Y
, then Enter
).
Apply changes:
source ~/.bashrc
.zshrc
)If you use Zsh, edit .zshrc
:
nano ~/.zshrc
Add:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use default
Save, then apply changes:
source ~/.zshrc
Close and reopen the terminal, then run:
node -v
It should return 6.11.2
. If not, try:
nvm use 6.11.2
nvm alias default 6.11.2
Then restart the terminal.
Sometimes, a system-wide Node.js version (/usr/bin/node
) conflicts with nvm
. Check if this is the case:
which node
If it returns /usr/bin/node
, then your system Node.js is overriding nvm
. To fix this, remove it (if you don’t need it):
sudo apt remove nodejs
Then restart the terminal.
Upvotes: 0
Reputation: 21
I had encountered this before. I removed the old Node.js installed in my machine, re-install the NVM and it works like a charm.
Upvotes: 0
Reputation: 4204
If your nvm command not updating your node version in windows, for example
Your current version is 6.11.2
and you would like to update to 8.11.3
using nvm use 8.11.3
in windows OS then below hack will do that job.
Renamed C:\Program Files\nodejs
to C:\Program Files\nodejsx
it worked for me.
Credit goes to user ituasdu
Upvotes: 5
Reputation: 2553
From the readme of NVM, under important notes:
Note: nvm does not support Windows (see #284). Two alternatives exist, which are neither supported nor developed by us:
- nvm-windows
- nodist
Upvotes: 1