Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
HTML5 Data and Services Cookbook

You're reading from   HTML5 Data and Services Cookbook Take the fast track to the rapidly growing world of HTML5 data and services with this brilliantly practical cookbook. Whether building websites or web applications, this is the handbook you need to master HTML5.

Arrow left icon
Product type Paperback
Published in Sep 2013
Publisher Packt
ISBN-13 9781783559282
Length 480 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (21) Chapters Close

HTML5 Data and Services Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Display of Textual Data 2. Display of Graphical Data FREE CHAPTER 3. Animated Data Display 4. Using HTML5 Input Components 5. Custom Input Components 6. Data Validation 7. Data Serialization 8. Communicating with Servers 9. Client-side Templates 10. Data Binding Frameworks 11. Data Storage 12. Multimedia Installing Node.js and Using npm Community and Resources Index

Using npm


The node package manager npm comes with the Node.js installer. npm is used for the command line; to use it, we will need to run a terminal program (a command prompt).

On Windows, we can use the basic cmd.exe, or alternatively, we can download and install Console from http://sourceforge.net/projects/console/.

On Mac OS X, Terminal.app can be used to run commands.

On Linux, use your favorite terminal. The default on Ubuntu Linux is the gnome terminal.

Open the terminal and type: npm. This command runs npm without any parameters. As a result, npm will print a general usage overview listing the available subcommands.

Installing a local package

Let's create an empty directory for our project named test, navigate to that directory, and install the underscore library there, using npm. Run the following commands:

mkdir test
cd test
npm install underscore

The last command will tell npm to run the install subcommand with the argument underscore, which in turn will install the package underscore locally. npm will output some progress information as it downloads and installs the package.

When installing a package locally, npm creates a subdirectory in the current directory named node_modules. Inside that directory, it creates another directory for the installed package. In this case, the underscore package will be placed inside the underscore directory.

Installing a global package

Some npm packages are designed to be installed globally. Global packages add new functionality to the operating system. For example, the coffee-script package can be installed globally, which will cause the command coffee to become available on our system.

To install global packages we use the -g switch. Have a look at the following example:

npm install -g coffee-script

On some systems it's necessary to request the administrative privilege to run this program. You can do that by using the sudo command:

sudo npm install -g coffee-script

npm will download and install coffee-script along with all its dependencies. After the process is complete, we can start using the command coffee, which is now available on our system. We can now run coffee-script code. Lets say we want to run a simple hello-world script written in-line; we can use the -e switch for that. Have a look at the following example:

coffee -e "echo 'Hello world'"

To learn more in the global package about npm subcommands, we can use npm's help subcommand. For example, to learn more about the install subcommand, run the following command:

npm help install

More information about the latest version of npm can be found on the official npm documentation at https://npmjs.org/doc/.

lock icon The rest of the chapter is locked
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
Banner background image