Installing Node.js
To easily install Node.js, download an installer from the Node.js website at http://nodejs.org. The Node.js installer installs the necessary files on your PC to get Node.js up and running. No additional configuration is necessary to start creating Node.js applications.
Looking at the Node.js Install Location
If you look at the install location, you will see a couple of executable files and a node_modules folder. The node executable file starts the Node.js JavaScript VM. The following list describes the executables in the Node.js install location that you need to get started:
node: This file starts a Node.js JavaScript VM. If you pass in a JavaScript file location, Node.js executes that script. If no target JavaScript file is specified, then a script prompt is shown that allows you to execute JavaScript code directly from the console.
npm: This command is used to manage the Node.js packages discussed in the next section.
node_modules: This folder contains the installed Node.js packages. These packages act as libraries that extend the capabilities of Node.js.
Verify Node.js Executables
Take a minute and verify that Node.js is installed and working before moving on. To do so, open a console prompt and execute the following command to bring up a Node.js VM:
node
Next, at the Node.js prompt execute the following to write "Hello World" to the screen.
>console.log("Hello World");
You should see "Hello World" output to the console screen. Now exit the console using Ctrl+C in Windows or Cmd+C on a Mac.
Next, verify that the npm command is working by executing the following command in the OS console prompt:
npm version
You should see output similar to the following:
{ npm: '3.10.5', ares: '1.10.1-DEV', http_parser: '2.7.0', icu: '57.1', modules: '48', node: '6.5.0', openssl: '1.0.2h', uv: '1.9.1', v8: '5.1.281.81', zlib: '1.2.8'}
Selecting a Node.js IDE
If you are planning on using an Integrated Development Environment (IDE) for your Node.js projects, you should take a minute and configure that now as well. Most developers are particular about the IDE that they like to use, and there will likely be a way to configure at least for JavaScript if not Node.js directly. For example, Eclipse has some great Node.js plugins, and the WebStorm IDE by IntelliJ has some good features for Node.js built in. If you are unsure of where to start, we use Visual Studio Code for the built-in TypeScript functionality required later in this book.
That said, you can use any editor you want to generate your Node.js web applications. In reality, all you need is a decent text editor. Almost all the code you will generate will be .js, .json, .html, and .css. So pick the editor in which you feel the most comfortable writing those types of files.