Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MEAN Web Development

You're reading from   MEAN Web Development Master real-time MEAN web application development and learn how to construct a MEAN application using a combination of MongoDB, Express, AngularJS, and Node.js

Arrow left icon
Product type Paperback
Published in Sep 2014
Publisher Packt
ISBN-13 9781783983285
Length 354 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Amos Q. Haviv Amos Q. Haviv
Author Profile Icon Amos Q. Haviv
Amos Q. Haviv
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Introduction to MEAN FREE CHAPTER 2. Getting Started with Node.js 3. Building an Express Web Application 4. Introduction to MongoDB 5. Introduction to Mongoose 6. Managing User Authentication Using Passport 7. Introduction to AngularJS 8. Creating a MEAN CRUD Module 9. Adding Real-time Functionality Using Socket.io 10. Testing MEAN Applications 11. Automating and Debugging MEAN Applications 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

The Node.js version scheme works in a way similar to that of MongoDB, where even version numbers mark stable releases, and so versions 0.8.x and 0.10.x are stable, while 0.9.x and 0.11.x are unstable releases and should not be used in production. The latest stable version of Node.js is 0.10.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 the http://nodejs.org/download/ page 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:

Installing Node.js on Windows

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 Node.js was successfully installed:

Installing Node.js on Windows

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 http://nodejs.org/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:

Installing Node.js on Mac OS X

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 offer 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:

Installing Node.js on Mac OS X

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/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-v0.10.31.tar.gz
$ cd node-v0.10.31
$ ./configure && make && sudo make install

If everything goes well, this will install Node.js on your machine. Note that these commands are for the Node.js 0.10.31 version, so remember to replace the version number to the version you downloaded. If you encounter any problems, the team behind Node.js has created a set of alternative installation options for you, documented at https://github.com/joyent/node/wiki/installation.

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 successfully installed Node.js, you will now 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!');
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 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.

You have been reading a chapter from
MEAN Web Development
Published in: Sep 2014
Publisher: Packt
ISBN-13: 9781783983285
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime