What are the differences between node.js and node? - node.js

I've installed node.js in my machine (linux mint 15), when I run node example.js, it says:
The program 'node' can be found in the following packages:
* node
* nodejs-legacy
Try: sudo apt-get install <selected package>
So what are the differences between node and nodejs? I had both node.js and node installed previously, but when I run node example.js, the web server doesn't start at all. So I deleted node and kept node.js.

The package node is not related to node.js.
nodejs is what you want, however it is arguably better to have the command be called node for compatibility with scripts that use #!/usr/bin/env node.
You can either just create a symlink in your path:
sudo ln -s `which nodejs` /usr/local/bin/node
Or you could install nvm and then use it to install the latest version of node.js:
nvm install stable
I prefer the nvm method, as it allows you to sudo apt-get remove nodejs, and then manage which version of node you're using yourself. You can also have multiple versions of node.js installed and use nvm use <version> to easily switch between them.
I also like to add a line to the bottom my .bashrc like: nvm use stable > /dev/null. That will automatically use the latest version you have installed.
To update your node version to the latest stable: nvm install stable. Every time you do this you will need to install any npm packages that you had installed globally if you want to continue using them.
To switch to an old version just run nvm use <version>, or, if you don't have the old version installed already: nvm install <version>.

This answer is just to tell you the difference between node and nodejs packages on Debian OS.
node
Amateur Packet Radio Node program.
Package details link: https://packages.debian.org/source/wheezy/node
nodejs
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Package details link:
https://packages.debian.org/source/sid/nodejs

There is a simple answer.
Node.JS is the script/code
Node compiles and runs the Node.JS

Related

Downgrading to a different version of Node

I accidently upgraded my Node server and it broke some stuff.
I'm using robot-js that only supports these versions of node - https://github.com/Robot/robot-js-binaries/tree/gh-pages/addon/1.0.2
How do I erase my current version and install the darwin-x64-14.node one?
I can't quite figure out the right command to install node-darwin-x64. What version do I put in?
https://www.npmjs.com/package/node-darwin-x64#download
I personally prefer to use nvm instead of directly installing node.js
it allow me to change any version of node instantly.
you can find a detailed instruction of how to uninstall node here.
then install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
then to install a specific version of node just use
nvm install any-version
to change to a specific node installation
nvm use version
please for osx installation refer to the Important Notes section on their readme https://github.com/creationix/nvm

Node Js - Upgrade version, migration guide

I have Node version v6.10.0 with Node Express 4.14.1. I want to upgrade Node version to 7.6 or 8 to make use of async await features.
However, I'm not sure if it is as simple as update node with the command line or if there is something I should be aware of before migrating.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
I have not found any migration guide on the site, github or whatsoever Internet.
Is it as simple as that as running a terminal instruction and done?
Try Using nvm,using nvm,We can easily switch between different versions of node js.
To Download nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Install a Particular Version Of Node
nvm install version
Use a Node Version
nvm use version

Downgrading NodeJs to below version using `n` package Not Working?

I have a virtual machine running Bitnami and my current Nodejs version is v9.8.0 but i wanted to change my version to 8.11.1 and to do that i used n npm package but still the version of NodeJs is same.
I used below commands
sudo npm cache clean -f
sudo npm install -g n
sudo n 8.11.1
Can anyone please help me.
Bitnami Engineer here.
Bitnami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system. This means that you don't have to worry about installing any other software on your system to make the new application work. They also won't interfere with any software already installed on your system, so everything you're already running will continue to work normally.
In this case, the PATH environment variable is configured to use the Bitnami binaries before the system's ones
PATH=/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
In case you try to find all the node binaries in the system
bitnami#bitnami-nodejs-dm-1072:~$ which -a node
/opt/bitnami/nodejs/bin/node
/opt/bitnami/nodejs/bin/node
/usr/local/bin/node
The first 2 "node" is the Bitnami's ones, the 3rd one is the system's one. If you use it, you will have the new Node.js version that you installed
bitnami#bitnami-nodejs-dm-1072:~$ /usr/local/bin/node --version
v8.11.1

can't revert to older version of node, can't uninstall node, OSX

Have installed node 0.12.2, but need to revert to 0.10.33 to run the applications I need to.
I have tried installing 0.10.33 and switching versions using
set 0.10.33 to default with 'nvm alias default 0.10.33'
But node runs previous version (0.12.2) when started again.
I have tried uninstalling node via various methods, but each one has been blocked:
uninstall node
"You must be in root to run this tool"
(I am the only user (with Admin access) on my machine
I tried
cd /
then
uninstall node
But still got
"You must be in root to run this tool"
Tried
sudo uninstall node
"Uninstall Failed...
Reason: ErrorMissingBundle"
I may have installed node with Homebrew - it was a while back, can't quite remember. So tried:
brew uninstall node
"Error: No such keg: /usr/local/Cellar/node"
Other information I can give:
which node
/usr/local/bin/node
I see node and npm in
/usr/local/bin
Any help most appreciated - I'm not a command line expert, and fairly new at Node.
To switch from different node.js version with nvm just use nvm use 0.10.33
It looks like you might be using NVM (node version manager). If you are you can install different versions using
nvm install version_no
and then you can switch versions using the command
nvm use version_no
If you have not used NVM to install node you can uninstall node using the instructions in this answer - How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X).
Then if you need different versions of node I would recommend using NVM, which allows you to install and use different versions of node on the same system. https://github.com/creationix/nvm

How to backup my Node.js setup when upgrading

I want to upgrade Node.js on Ubuntu, but I want to make sure that if anything goes wrong I could revert back my source code, installed modules and node binary to the working setup. How to achieve that?
You can install any version of node.js just go to downloads. Go into Other Releases and download what version you want with respect to your OS and 32-bit or 64-bit.
Example:
node-vX.XX.X-OS-x64.tar.gz (64-bit)
node-vX.XX.X-OS-x86.tar.gz (32-bit)
Then, follow the instruction on the github.com. Building and installing Node.js
Another way is to use NVM, the Node Version Manager (it works in a very similar way to rvm for ruby). This allows to install and manage multiple versions of node. Here's a snippet (source):
Usage:
nvm install <version> Download and install a <version>
nvm use <version> Modify PATH to use <version>
nvm ls List versions (installed versions are blue)
You can also check this n. A Simple flavour of node binary management.
Update (as per comments):
If you have installed the nvm after node.js. You can check already installed by using nvm ls which lists already installed version(s) ready to use.
amolkulkarni#ubuntu:~$ nvm ls
current: v0.10.18
You should use Node Version Manager https://github.com/creationix/nvm

Resources