As I run this piece of code using node a.js
:
var sys = require(\'sys\');
sys.puts(\'Hello, World\');
I\'m getting the following as a
The easiest way is to remove the node installation first and then install npm. npm is the Node Package Manager, this will automatically install nodejs itself
Brandon Helwig is correct. It just happened to me. In general, if you get this type of error, you have installed the wrong package. Here are more instructions for you to install one of the latest versions of Node.js.
Fix
sudo apt-get remove node
This will remove the accidentally installed package. Both names for the package node
and nodejs
are the same which is node
.
If you do sudo apt-get install node
, what you would get is a old version. But thanks for Chris Lea, we got a PPA for this task.
sudo apt-get update
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
This should get you the latest version of Node.js
in your application.
If you are in need of an bleeding edge version, you can install from the source. But I think this is way cleaner.