Need Advice: Latest version of Node.js vs using Synaptic Package Manager? - node.js

I'm trying to get node.js and npm installed on my Ubuntu 11.10 installation, and I'm having a tricky time. I decided to go the route of downloading and compiling from the latest source because I want to use the new version of node.js - v0.6.0 instead of the older version that the synaptic package manager will install. However, I could not get npm set up correctly with it due to a "module not found" error. I was completely surprised at how little information I was able to find on the error.
Anyways, my goal here is to learn node.js, not to run a production environment. Should I give in and use v4.9 or is it really worth getting the newest version for the sake of learning, even if I have to go through the pain of keeping it updated and configuring it myself?

If you have Ubuntu, install it from Chris Lea's repo, it's always up to date with the last stable version (for ex now the version is 0.6.0 - as of today):
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Generally, you want to install node from source since the packages you find in package managers are usually out of date. 0.4.12 was the last stable before 0.6.0 that was released a few days ago. 0.4.9 is pretty out of date.

This is a old question, nowadays my preferred way to install node is by using nvm (Node Version Manager). This will allow you to have multiple versions of node installed and quickly switch version.
Installation:
Install C++ compiler
apt-get update
apt-get install build-essential libssl-dev
Install NVM
curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
source ~/.profile
Install node (select which version you want to install)
nvm install 6
Usage:
To set a default node version:
nvm alias default 0.12.7
To select a different installed version:
nvm use 4

Related

How to install node-v6.11.0-linux-x86.tar.xz in Ubuntu

I'm a windows user and I'm having a difficulty installing the latest version of NodeJS.
I've tried sudo apt-get install -y nodejs and it installed v0.10.25 version.
Can someone guide me how to install the tar.xz file properly.
Use nvm
It'll take care of everything.

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

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.

How to install latest stable version of node.js on centos 7

How to install latest stable version of node.js on centos 7 ?
What is the easiest way to install latest node.js + nvm + npm on CentOS 7
Without downloading the source code and compiling it.
Node builds binaries as well as providing source. For example you could grab https://nodejs.org/download/release/v5.3.0/node-v5.3.0-linux-x64.tar.gz and then extract into the proper hierarchy.
woo, I just instlled successfully these days, the offical stable version I just forgot.Beause in China sometimes I cannot open its offical net (you know that)
you can use following command to install:
wget http://nodejs.org/dist/node-v0.6.9.tar.gz
tar xvf node-v0.6.9.tar.gz
cd node-v0.6.9
yum install gcc gcc-c++ openssl-devel #一些软件包/nodejs need this package
./configure
make && make install
node--version #查看版本信息/check version info
if you wanna install other version just open http://nodejs.org/dist
to check
Finish

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.

Installed node.js ver 0.8 but node --version still shows previous version 0.6.12

I tried installing node ver 0.8 on my ubuntu 12.04.It already has a node ver 0.6.12.The installation went suceesfully but when i type in
node --version
it still shows previous version.
i tried to remove previous version using sudo apt-get remove node but it says package node is not installed.But on trying node --version it shows 0.6.12
Why is it so??
The problem is, you need to replace the new location for node with the old in your PATH variable. If you have an old manual install, find the old path to node by running echo $PATH. Then run this command:
export PATH=${PATH%$OLD_NODE_PATH/bin*}$NEW_NODE_PATH/bin${PATH#$*OLD_NODE_PATH/bin}
Or if you are using an install from the apt-get repository, just run:
export PATH=$NEW_NODE_PATH/bin
And that should fix your problem. But there is a better way! The best tool to manage your node.js environment is NVM. It exactly like RVM for ruby and similar to virtualenv for python, if you are familiar with those tools. It allows you to switch versions of node and download new ones extremely efficiently, and is easy to use. Download and install with:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
Then add this line to your bash (assuming you are running a bash shell) where it will be loaded (I prefer .bash_login for the personal stuff although it is not loaded by default):
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh
Source your bash script or restart the terminal then enter this command:
nvm install 0.8.0 && nvm use 0.8.0
This should set you up just fine. Although not necessary, you should probably get rid of all the other node installs, for the sake of tidiness. Check out their github page but to get you started here is a quick overview:
nvm ls # list all installed versions of node
nvm ls-remote # list all available versions of node
nvm install 0.9.8 # download and install node v0.9.8
nvm use 0.8.0 # switch current environment to use node v0.8.0
nvm alias default 0.8.0 # set 0.8.0 as default, you can use 'nvm use default'
nvm deactivate # use system install of node
nvm run default app.js # run app.js with default node version
I had this issue until I followd the directions on
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
which included running:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
first. Then running sudo apt-get install nodejs npm got me to 0.8.x
Also see: http://apptob.org/
Seem like you install nodejs package from Ubuntu repo and manually install node 0.8 after?
Try remove nodejs package.
The way to get a more recent version of Node.js is to add a PPA (personal package archive) maintained by NodeSource. This will probably have more up-to-date versions of Node.js than the official Ubuntu repositories.
First, you need to install the PPA in order to get access to its contents:
curl -sL https://deb.nodesource.com/setup | sudo bash -
The PPA will be added to your configuration and your local package cache will be updated automatically. After running the setup script from nodesource, you can install the Node.js package using the below command.
sudo apt-get install nodejs
You can check the node by using this command
node -v

Resources