Verifying Node.js Installation

If you have used Windows MSI installer, or Linux/OSX package manager, then the path to Node.js bin directory is already added to PATH environmental variable. If path is setup, you could launch the Node.js REPL terminal by typing node from anywhere. If the command node is not recognized, that means path is not setup.

C:\> node
>

REPL (Read Eval Print Loop) is an interactive environment that can read input, evaluate expressions, print the result and loop until user presses Ctrl+C twice or Ctrl+D once.

> console.log('Hooray!')
Hooray!
undefined
>

To terminate the REPL, press Ctrl+C twice or Ctrl+D once. To exit the currently running program press Ctrl+C.

The output to the console is text 'Hooray' as well as return value of the console.log() function. The return value is undefined. This can be ignored because we are not concerned with the return value of the function.

Instead of using the REPL, you could try executing a simple JavaScript file. Create a file called hello.js with the following content:


console.log('Hello World');

If you run this with Nodejs interpreter from command line or Linux shell, it will output the text Hello World to the console.

C:\MyApp> node hello.js
Hello World

To check Node.js version installed on your machine,

C:\> node -v
V6.9.4

Now that Node.js is installed and verified you can move on to creating simple applications using Node.js


Post a comment

Name

Your Comment

Email (We dont publish it)

Comments

Nothing yet..be the first to share wisdom.