Installing Node.js and browser-sync

There is one final set-up step before you begin your first project.

Node.js (or simply Node) lets you use programs written in JavaScript from the command line. Most front-end development tools are written for use with Node.js. You will learn lots more about Node.js in Chapter 15, but you will begin using one tool that depends on it, browser-sync, right away.

Install Node by downloading the installer from nodejs.org (Figure 1.27). The version of Node.js used in this book is 5.11.1, and you will likely see a different version available for download.

Figure 1.27  Downloading Node.js

Downloading Node.js

Double-click the installer and follow the prompts.

When you install Node, it provides two command-line programs: node and npm. The node program does the work of running programs written in JavaScript. You will not need to use it until Chapter 15. The other program is the Node package manager, npm, which is needed for installing open-source development tools from the internet.

browser-sync is one such tool, and it will be invaluable to you throughout the book. It makes your example code easier to run in the browser and automatically reloads the browser when you save changes to your code.

Install browser-sync using this command at the command line:

npm install -g browser-sync

(The -g in the command stands for “global.” Installing the package globally means that you will be able to run browser-sync from any directory.)

It does not matter what directory you are in when you run this command, but you will probably need superuser privileges. If that is the case, run the command using sudo on a Mac:

sudo npm install -g browser-sync

If you are on Windows, first open a command prompt as the administrator, as shown above.

When you start browser-sync, as you will in the next chapter, it will run until you press Control-C. It is a good idea to quit browser-sync when you are done working on a project for a while. That means that you will need to start browser-sync each time you begin work on the first two projects in this book (Ottergram and CoffeeRun).

With that, you have the tools you need to get started on your Ottergram project!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.225