You can get and install Node from it’s main site nodejs.org where you will find a version for all major OS. If you are using a Debian based distribution you can of course do:
1 sudo apt-get install nodejs
Trying it out
If you type nodejs(Just node in some systems) on your terminal you will get the node prompt:
1 2 3 4 5 6 7 > var greetings = "Hello"; undefined > console.log(greetings); Hello undefined > greetings 'Hello'
By default the interactive console always prints the return value of the executed statement, that is the reason we see undefined printed in the second line, because there is no value returned from the first statement.
Other important thing to have in mind is that node doesn’t run inside of a browser, so functionality that is inherent from the browser is not available. Here are some examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 > window ReferenceError: window is not defined at repl:1:2 at REPLServer.eval (repl.js:80:21) at Interface.<anonymous> (repl.js:182:12) at Interface.emit (events.js:67:17) at Interface._onLine (readline.js:162:10) at Interface._line (readline.js:426:8) at Interface._ttyWrite (readline.js:603:14) at ReadStream.<anonymous> (readline.js:82:12) at ReadStream.emit (events.js:88:20) at ReadStream._emitKey (tty.js:327:10) > alert('hello'); ReferenceError: alert is not defined at repl:1:1 at REPLServer.eval (repl.js:80:21) at repl.js:190:20 at REPLServer.eval (repl.js:87:5) at Interface.<anonymous> (repl.js:182:12) at Interface.emit (events.js:67:17) at Interface._onLine (readline.js:162:10) at Interface._line (readline.js:426:8) at Interface._ttyWrite (readline.js:603:14) at ReadStream.<anonymous> (readline.js:82:12)
NPM stands for node package manager. This tool provide an easy way to install and manage node modules that you may need to build your applications. If you installed node using a package from nodejs.org you probably already have npm, if you use Debian you can also do:
1 sudo apt-get install npm
And you can install packages by using
1 npm install package-name
This is all for my introduction but I will be writing more about node in the future.