How do you install newest version of node.js on Raspberry Pi? - node.js

I want to install the latest stable version of Node.js on Raspberry Pi 3. How do I do it in such a way that a) I'm always able to update to latest LTS version b) Can easily switch between versions

The Node version manager works great, even for ARM based processors (like Raspberry Pi).
You need to remove the existing version of node installed on Raspbian however (if you are using this distro):
Remove old:
sudo -i
apt-get remove nodered -y
apt-get remove nodejs nodejs-legacy -y
exit
Install n (it will also install latest stable Node.js):
curl -L https://git.io/n-install | bash
Verify:
pi#raspberrypi:~ $ node --version
nv7.6.0
pi#raspberrypi:~ $ npm --version
4.1.2

If you've installed nvm, you can use nvm install latest or nvm install stable.
That's the best way to keep it up-to-date. You could write a bash script to handle keeping your Node.js version in sync with the latest using nvm.

Related

Node JS - Not able to install node js version 8.9 or greater in ubuntu 16.04

I have tried various methods by which I can install the latest version of nodejs on my operating system but was unsuccessful.
In the end it always ends up installing
version v.4.2.6
When I run the commands below, it always shows an error as shared in the screenshots of my terminal.
Current release:
sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
or LTS release:
sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
// throws error
Version:
Trying to execute node 11 script:
o/p of the above script:
Please guide me how can it be fixed. I have followed some of the other stackoverflow links but couldn't make it.
Thanks you for your help.
I recommand uninstalling your current NodeJS version and install nvm instead.
Then you can manage all node version with nvm.
Method 1:
I followed this link and it was successful:
updating nodejs on ubuntu 16.04
Method 2:
You can either skip above link and follow the below steps:
Using Node Version Manager (NVM):
Install it by following instructions here
Test your installation:
close your current terminal, open a new terminal, and run:
command -v nvm
Use it to install as many versions as u like:
nvm install 8 # Install nodejs 8
nvm install --lts # Install latest LTS (Long Term Support) version
List installed versions:
nvm ls
Use a specific version:
nvm use 8 # Use this version on this shell
Set defaults:
nvm alias default 8 # Default to nodejs 8 on this shell
nvm alias default node # always use latest available as default nodejs for all shells
If you have npm installed -
run
sudo npm cache clean -f
sudo npm install -g n
install n globally
npm i -g n
then switch to the latest stable node version using n
n stable

How to install nodejs 6.x version on centos 6?

I use centos release 6.9
current nodejs version v0.10.48
I want install nodejs 6.x version
and I try
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install nodejs
but occur error
enter image description here
how to install nodejs 6.x version on centos 6?
The easiest way is use n to switch the node version
To avoid some issue after version changed, please run this command.
npm cache clean -f
Then install n
npm i -g n
Now, use n install node version you want. (I suggest you lts one.)
n lts
here is n documentation https://github.com/tj/n

Installing node 7 on Centos machine

I am trying to install node 7 on my Centos machine because previous versions do not support the apn protocol for sending iOS notifications. So I tried to execute:
sudo yum install nodes
and both npm and node were installed but unfortunately the latter of version v6.10.0.
sudo npm install latest
changes nothing.
I found a post suggesting to update the rpm repository, but that changes nothing; I even tried to change the command to:
sudo curl -sL https://rpm.nodesource.com/setup_7.x | sudo -E bash -
but when I tried to install node again, still the 6.10 version came out.
How may I force npm to adopt node7 as the stable or latest version?
Or what other way there exists to install node 7 instead of 6.10 for the good?
Another way is to use nvm (Node Version manager). First remove node and npm, then :
curl https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 7
nvm use 7
Then check version with :
node -v
nvm ls

How to install nodejs 6.7.0 on Ubuntu 14

I have found some guides (for ex. Install latest nodejs version in ubuntu 14.04) how to install updated version of NodeJS, also followed the official one that says to use
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
which is the same thing as in the SO guide above.
However, the version of node I get is 6.3.1 but I want the latest 6.7.0. I have installed 6.7.0 on OSX via brew but don't know how to get it on Ubuntu. Is there any way to do it, using APT preferably?
I have done this way:-
sudo npm install n -g
sudo n 6.7.0
Alternatively for latest stable version you can do this:-
sudo n stable
And For latest version
sudo n latest

How to install nodejs 0.12.7

I've trying to install the latest version of nodejs
sudo apt-get nodejs
installs the version 0.12.25
When I downloaded the tar.gz from https://nodejs.org/ and installed
my node version upgraded to 0.12.7 but not nodejs version.
And when I tried like this
sudo apt-get install nodejs=0.12.7
E: Version '0.12.7' for 'nodejs' was not found
This error popped up. What can I do such that on entering
nodejs -v
I can get 0.12.7
Since there are a lot of Node.js versions, and there is also iojs, I suggest you to use a straightforward Node.js version manager, like the very good n.
So, first install n, then install Node.js 0.12.7 with:
$ n 0.12.7
When you install node.js from source by default it will install with node as name of the executable
node -v
Will show 0.12.7
If you need node.js for development purposes on your machine you can use nvm, it allows to install different versions of node.js and io.js, and easily switch between them
Remove node with command sudo apt-get remove node, then remove nodejs using sudo apt-get remove nodejs. After that try to install nodejs again with version you need sudo apt-get install nodejs=0.12.7.

Resources