My nvm keep forgetting about the node environment ever since I upgraded to Yosemite(A few months ago)/Capitan EL(I upgraded this week) even though I did
nvm alias default 0.12
Hilariously, it told me after I hit enter
default -> 0.12 (-> v0.12.8)
But when I opened a new terminal it said node: command is not found!!
There are a couple of solutions I tried so far:
I have tried using brew uninstall nvm & brew install nvm
as well as the installing script, since brew complaint it doesn't work with the pre-released OS(which is actually GA right now)
I double checked bash_profile do have the following lines
export NVM_DIR=~/.nvm
source $NVM_DIR/nvm.sh
Unfortunately, none of them works. Have anyone run into a similar issue before?
Thanks!
This is merely a temporary solution, however, it works.
Add nvm use stable in ~/.bash_profile(or whatever version you want to use to replace stable)
Save the file
Do source ~/.bash_profile after this or simply open a new terminal tab.
I just used this command in MacOS el capitan
$> nvm alias default v6.4.0
It worked as expected. Please notice the small v before the version number.
And finally, just if it helps, I used this command to install nvm as is described in the nvm project readme.
$> curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
This worked for me on El Capitan
brew uninstall nvm
brew install nvm
mkdir ~/.nvm
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
It said that .nvm folder already existed but I ignored that.
Related
Currently, I have node version 10.10.0. I want to install it with the latest version. On my ubuntu 18.4 LTS bionic.
I tried using
url -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install nodejs
node -v
but it still shows the older version
I have also tried
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 12.12.0
these steps show 12.12.0 version on node -v command, but when I open a new terminal or virtual environment it again shows the older version which is 10.10.0. Please provide a solution.
You need to use a node version manager and set the default node version. Use below command to set the default version.
nvm alias default <version>
e.g nvm alias default 12.12.0
You can use nvm use 12 to make the terminal recognize which version you want to use
I just did pip3 install npm.
Worked for me.
I installed a brand new ubuntu 16.04 64-bit on my VirtualBox. Here is what I did to install latest version nodejs:
go to https://nodejs.org/, click on 12.16.1 LTS, which is the latest version I could get. download will be initiated in a few seconds
create a folder for nodejs(if not exist):
sudo mkdir -p /usr/local/lib/nodejs
uzip to the folder just created:
sudo tar -xJvf node-v12.16.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
set the environment variable ~/.profile, add below to the end of the file(make sure you don't have duplicate in this file)
# Nodejs
VERSION=v10.15.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
refresh the profile
. ~/.profile
Congratulations! Now if you issue node -v, you should get v12.16.1.
This may not be the optimal way to update the nodejs if you currently have one previous version installed, but it can let you choose which one to keep (by modifying the PATH, another file you may want to touch is /etc/profile).
I also suggest you uninstall current nodejs (e.g. sudo apt-get purge node) before proceed to install the lastest one.
Reference:
Installation - nodejs help page on github
On Ubuntu 16.04, I mistakenly used root to install nvm, and then to install node.js 8.8.1 via nvm. I also used nvm alias default 8.8.1, thinking it would correct my error.
Now I would like to:
Remove the default alias
Uninstall node 8.8.1
Uninstall npm 4.8.5, which came along with node
Uninstall nvm
Reinstall everything correctly for the right non-sudo user
It looks like I've succeeded with the first part:
# nvm unalias default
Deleted alias default - restore it with `nvm alias "default" "8.8.1"`
But nvm refuses to uninstall node 8.8.1, because it is the only version installed:
# nvm uninstall 8.8.1
nvm: Cannot uninstall currently-active node version, v8.8.1 (inferred from 8.8.1).
I am guessing that I first need to disactivate node 8.8.1, but I see nothing in the output of nvm --help which would appear to do this.
What steps do I need to take to completely remove node.js, npm and nvm from the machine before re-installing everything correctly?
First type
$ nvm deactivate
Then type
$ nvm uninstall 8.8.1
rm -Rf ~/.nvm
This is the nuclear option in my case. just -R would ask me if I really wanted to delete every file in the nvm folder.
You can uninstall the nodejs by using the following command.
yum remove nodejs
However, this will not remove the nvm from your linux box. To remove that try the below command.
nvm unload
nvm deactivate
can temporarily deactivate the nvm'ed node.
You can comment out the path in .zshrc etc, for the next session.
#export NVM_DIR="$HOME/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
I'm attempting to get the LTS version of node installed on my machine via homebrew but I seem to be having some issues. If I run brew install node#6 to get the latest LTS version (6.10.3), everything seems to complete with no issues. Then, if I run brew list, I will see node#6 has indeed installed. BUT, if I check which version of node is installed using node -v, I receive zsh: command not found: node. I'm pretty new to homebrew and the command line in general. Where have I gone wrong?
Any help would be greatly appreciated, and I can provide more info if requested. Thanks!
For those curious, I ended up just using brew install node to install the most current version of node. Trying to install node#6 was troublesome, but it seems my struggle was pertaining to an issue where homebrew required node#6 to be linked using brew link node#6 --force. More info can be found here:
https://github.com/Homebrew/brew/issues/2220
Note that I did not try this solution.
As indicated in the GitHub issue linked above, if you run brew info node#10 (replace node#10 with your version) it provides a line to add the non-latest node version to your path:
If you need to have node#10 first in your PATH run:
echo 'export PATH="/usr/local/opt/node#10/bin:$PATH"' >> ~/.zshrc
Running echo 'export PATH="/usr/local/opt/node#10/bin:$PATH"' >> ~/.zshrc adds a line to the bottom of my .zshrc file:
export PATH="/usr/local/opt/node#10/bin:$PATH"
If you're using Bash, it'd be your .bashrc file. I'm guessing Homebrew picks up on that, but worth double checking.
This line will add /usr/local/opt/node#10/bin to my PATH when I start my terminal. I need to restart my terminal to get immediate access. Or I can re-source the .zshrc file. I only have to do this the first time:
source ~/.zshrc
Now node works. I can verify by checking the version:
node -v
# v10.17.0
Could you check if /usr/local/bin is in your $PATH? Also, maybe run brew doctor?
Is it possible to upgrade node right in place, instead of manually installing the latest stable version?
I have installed node.js version 5.0 with nvm, but now I want to update it to 5.4. I'm trying to avoid having to manually reinstall all of my global packages (e.g. by running npm install -g grunt-cli bower yo yoman-angular-generator blabla blablablabla...).
This may work:
nvm install NEW_VERSION --reinstall-packages-from=OLD_VERSION
For example:
nvm install 6.7 --reinstall-packages-from=6.4
then, if you want, you can delete your previous version with:
nvm uninstall OLD_VERSION
Where, in your case,
NEW_VERSION = 5.4
OLD_VERSION = 5.0
Alternatively, try:
nvm install stable --reinstall-packages-from=current
You can more simply run one of the following commands:
Latest version:
nvm install node --reinstall-packages-from=node
Stable (LTS) version: (if currently in use)
nvm install "lts/*" --reinstall-packages-from="$(nvm current)"
This will install the appropriate version and reinstall all packages from the currently used node version.
This saves you from manually handling the specific versions.
Kudos to #m4js7er for commenting about the LTS version.
⚡ TWO Simple Solutions:
To install the latest version of node and reinstall the old version packages just run the following command.
nvm install node --reinstall-packages-from=node
To install the latest lts (long term support) version of node and reinstall the old version packages just run the following command.
nvm install --lts /* --reinstall-packages-from=node
Here's a GIF animation to support this answer:
if you have 4.2 and want to install 5.0.0 then
nvm install v5.0.0 --reinstall-packages-from=4.2
the answer of gabrielperales is right except that he missed the "=" sign at the end. if you don't put the "=" sign then new node version will be installed but the packages won't be installed.
source: sitepoint
Here are the steps that worked for me for Ubuntu OS and using nvm
Go to nodejs website and get the last LTS version (for example the version will be: x.y.z)
nvm install x.y.z
# In my case current version is: 14.15.4 (and had 14.15.3)
After that, execute nvm list and you will get list of node versions installed by nvm.
Now you need to switch to the default last installed one by executing:
nvm alias default x.y.z
List again or run nvm --version to check:
Update: sometimes even if i go over the steps above it doesn't work, so what i did was removing the symbolic links in /usr/local/bin
cd /usr/local/bin
sudo rm node npm npx
And relink:
sudo ln -s $(which node) /usr/local/bin/nodesudo && ln -s $(which npm) /usr/local/bin/npmsudo && ln -s $(which npx) /usr/local/bin/npx
Node.JS to install a new version.
Step 1 : NVM Install
npm i -g nvm
Step 2 : NODE Newest version install
nvm install *.*.*(NodeVersion)
Step 3 : Selected Node Version
nvm use *.*.*(NodeVersion)
Finish
Bash alias for updating current active version:
alias nodeupdate='nvm install $(nvm current | sed -rn "s/v([[:digit:]]+).*/\1/p") --reinstall-packages-from=$(nvm current)'
The part sed -rn "s/v([[:digit:]]+).*/\1/p" transforms output from nvm current so that only a major version of node is returned, i.e.: v13.5.0 -> 13.
For Windows 11 this worked for me on cmd, used with admin rights:
Prerequisite, in case you just installed NVM, is to open a new cmd window after nvm installation.
See installation instructions here: https://github.com/coreybutler/nvm-windows
Get installed versions, using
nvm list
Get current version
nvm current
Install latest version
nvm install latest
Check installed versions to see for newer version, again using
nvm list
Set current version to the latest (cmd with admin rights), you just installed in the previous step
nvm use PUT_VERSION_NUMBER_TO_BE_USED
You can check again if the change was successful using
nvm list
Remove old version, if no longer needed
nvm remove PUT_VERSION_NUMBER_TO_BE_REMOVED
If you want to use the LTS version, install using
nvm install lts
Here's the steps to upgrade NodeJs version:
Run nvm install node (will install latest version). Alternatively, you
can specify a specific version by running nvm install <node_version>.
Run nvm use <node_version> to use it.
If you want to make it the default version on your machine, run nvm alias default <node_version>.
Additional notes:
To find out what node versions you have on your machine and which one is set as your default one, use nvm list command.
I'm trying to install nvm on Ubuntu 14.04 but it doesn't seem to use the version I specify. I installed following the tutorial here https://github.com/creationix/nvm and I've also tried the one here https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps.
There are 2 node installations on my system already.
which node # => /usr/local/bin/node
node --version # => v0.11.13-pre
which nodejs # => /usr/bin/nodejs
nodejs --version # => v0.10.26
When I install nvm using the curl one liner they give you, and then use
nvm install 0.10.32
It creates an empty folder inside .nvm/v0.10.32 and .nvm/current symlinks to it.
In addition the bin folder is also empty. This problem occurs if I install other
versions of node. I suppose I could just clone a version of node into the folder
its supposed to go in but idk if that's all I have to do. In addition, I'm not sure
I know how to make my system use the nvm current (symlink from /usr/local/bin/node to .nvm/current ?) Without doing anything myself and only following the tutorial, node --version and nodejs --version never uses the version I specify with.
nvm use 0.10.32
Here is my personal guide how to install nvm (node version manager).
reference: https://github.com/creationix/nvm
1.) Install nvm (NOTE: There might be new versions in their website.)
curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash
2.) Close the current terminal and use a new terminal then try nvm again.
3.) Install current node.js version by using:
nvm install node_version
ex: nvm install 0.10.32
4.) to check the nodejs version--> nvm list
5.) Setup a default node version in nvm so that everytime you restart
the system it loads a default node version:
to get help: nvm -h
to get list of install node.js versions: nvm ls
to set a default alias: nvm alias default node_version
6.) Uninstall a specific node.js version:
nvm uninstall node_version
I understand that my answer may be outdated, but there was a very nice thesis in the ticket #809, that using
$ npm install -g nvm
is wrong. To fix, you want to do
$ npm uninstall -g nvm
$ apt install curl
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
$ source ~/.bashrc
$ nvm install 5.1
$ nvm use 5.1
instead (given that curl hasn't yet been installed on that machine).
I just removed all of the offending node installations until my system used a version that was 0.10.* . It appears I tried to install node before or another program installed it.