Book Image

MEAN Web Development - Second Edition

By : Amos Q. Haviv
Book Image

MEAN Web Development - Second Edition

By: Amos Q. Haviv

Overview of this book

The MEAN stack is a collection of the most popular modern tools for web development that helps you build fast, robust, and maintainable web applications. Starting with the MEAN core frameworks, this pragmatic guide will explain the key concepts of each framework, how to set them up properly, and how to use popular modules to connect it all together. By following the real-world examples shown in this tutorial, you will scaffold your MEAN application architecture, add an authentication layer, and develop an MVC structure to support your project development. You will learn the best practices of maintaining clear and simple code and will see how to avoid common pitfalls. Finally, you will walk through the different tools and frameworks that will help expedite your daily development cycles. Watch how your application development grows by learning from the only guide that is solely orientated towards building a full, end-to-end, real-time application using the MEAN stack!
Table of Contents (18 chapters)
MEAN Web Development Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Installing Node.js


For the stable versions, the official Node.js website supplies linked binaries that provide the easiest way to install Node.js on Linux, Mac OS X, and Windows. Note that you need to download the right architecture version for your operating system. If you use Windows or Linux, make sure to download either the 32-bit or 64-bit version according to your system architecture. Mac users are safe to download the 64-bit version.

Note

After the merge between the Node.js and io.js projects, the version scheme continued directly from 0.12.x to 4.x. The team now uses the Long-term Support (LTS) policy. You can read about it at https://en.wikipedia.org/wiki/Long-term_support. The latest stable version of Node.js is 6.x.

Installing Node.js on Windows

Installing Node.js on a Windows machine is a simple task that can be easily accomplished using the standalone installer. To begin with, navigate to https://nodejs.org/en/download/ and download the right .msi file. Notice there are 32-bit and 64-bit versions, so make sure you download the right one for your system.

After downloading the installer, run it. If you get any security dialog boxes, just click on the Run button, and the installation wizard should start. You will be prompted with an installation screen similar to the following screenshot:

Node.js Windows installation wizard

Once you click on the Next button, the installation should begin. A few moments later, you'll see a confirmation screen similar to the following screenshot, telling you that Node.js was successfully installed:

Node.js Windows installation confirmation

Installing Node.js on Mac OS X

Installing Node.js on Mac OS X is a simple task that can be easily accomplished using the standalone installer. Start by navigating to the https://nodejs.org/en/download/ page and download the .pkg file. After downloading the installer, run it, and you will be prompted with an installation screen similar to the following screenshot:

Node.js Mac OS X installation wizard

Click on Continue, and the installation process should begin. The installer will ask you to confirm the license agreement and then ask you to select the folder destination. Choose the option most suitable for you before clicking on the Continue button again. The installer will then ask you to confirm the installation information and ask you for your user password. A few moments later, you'll see a confirmation screen similar to the following screenshot, telling you that Node.js was successfully installed:

Node.js Mac OS X installation confirmation

Installing Node.js on Linux

To install Node.js on a Linux machine, you'll have to use the tarball file from the official website. The best way of doing so is to download the latest version and then build and install the source code using the make command. Start by navigating to the http://nodejs.org/en/download/ page, and download the suitable .tar.gz file. Then, expand the file and install Node.js by issuing the following commands:

$ tar -zxf node-v6.9.1.tar.gz
$ cd node-v6.9.1
$ ./configure && make && sudo make install

If everything goes well, the commands will install Node.js on your machine. Note that these commands are for the Node.js 6.9.1 version, so remember to replace the version number with the version you downloaded.

Note

It is recommended that you learn more about Node.js by visiting the official documentation at https://nodejs.org.

Running Node.js

After you have successfully installed Node.js, you will be able to start experimenting with it using the provided command-line interface (CLI). Go to your command-line tool and execute the following command:

$ node

This will start the Node.js CLI, which will wait for a JavaScript input. To test the installation, run the following command:

> console.log('Node is up and running!');

The output should be similar to the one that follows:

Node is up and running!
undefined

This is nice, but you should also try to execute a JavaScript file. Start by creating a file named application.js that contains the following code:

console.log('Node is up and running!');

To run it, you'll have to pass the file name as the first argument to the Node CLI by issuing the following command:

$ node application.js
Node is up and running!

Congratulations! You have just created your first Node.js application. To stop the CLI, press CTRL + D or CTRL + C.