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! 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
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning Node.js for .NET  Developers
Learning Node.js for .NET  Developers

Learning Node.js for .NET Developers: Build server side applications with Node.js

Arrow left icon
Profile Icon Cummings
Arrow right icon
NZ$14.99 NZ$38.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (2 Ratings)
eBook Jun 2016 248 pages 1st Edition
eBook
NZ$14.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial
Arrow left icon
Profile Icon Cummings
Arrow right icon
NZ$14.99 NZ$38.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (2 Ratings)
eBook Jun 2016 248 pages 1st Edition
eBook
NZ$14.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial
eBook
NZ$14.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learning Node.js for .NET Developers

Chapter 2. Getting Started with Node.js

This chapter will get you up and running with Node.js. You'll see how quick this can be and how easy it is to start writing web applications. You'll also choose a development environment for working with Node.js. In this chapter, we will cover the following topics:

  • Installing Node.js
  • Writing our first Node.js web application
  • Setting up our development environment

Installing and running Node.js

To install Node.js, visit https://nodejs.org, and download and run the installer package for the currently recommended version. The examples in this book are based on Node.js v6, released in April 2016 and supported through to April 2018.

After installation, open up a console window (run command prompt on Windows, or terminal on Mac) and type node.

This opens the Node.js REPL, which works like the JavaScript console in browsers. Try typing in a few commands and see the output:

> function square(x) { return x*x; }
undefined
> square(42)
1764
> new Date()
2016-05-02T16:08:41.915Z
> var foo = { bar: 'baz' }
undefined
> typeof foo
'object'
> foo.bar
'baz'

Now let's make use of one of the Node.js-specific APIs to create an HTTP server. Type the following commands into the REPL (the output of each command is omitted from the listing below for brevity):

> var listener = function(request, response) { response.end...

Choosing an editor

Of course, we're not going to write all of our code inside the REPL. You can use any text editor or IDE you like for writing JavaScript for Node.js. If you're not sure what to use, try one of the following:

These are both free, lightweight IDEs that are actually implemented in Node.js. They are both available for Windows, Mac, and Linux.

The code listings in the rest of this book will be JavaScript source code files, not commands to be typed into the REPL.

Using an application framework

The server we created in the REPL used the low-level HTTP module built into Node.js. This provides an API for creating a server that reads data from requests and writes to responses.

As with other programming platforms, there are frameworks available providing more useful high-level abstractions for writing web applications. These include things such as URL routing and templating engines. ASP.NET MVC, Ruby on Rails, and Spring MVC are all examples of such frameworks on different platforms.

Note

Example code

If you get stuck at any point in this book, you can follow along with the code at https://github.com/NodeJsForDevelopers (there is a repository for each chapter and a commit for each heading that introduces any new code).

In this book, we'll be using a framework called Express to write a web application in Node.js. Express is the most popular web application framework for Node.js. It is well suited to small-scale applications such as the one we'll...

Summary

In this chapter, we installed Node.js, saw how to interact with it from the command line, and started using it to write web applications. We learned about Express and how we can structure an application using routes and middleware.

Although we've seen some code in this chapter, we haven't really explored the JavaScript syntax in detail. Before adding more functionality to our application, we should make sure that we're up to speed with JavaScript. This is the subject of the next chapter.

Left arrow icon Right arrow icon

Key benefits

  • Learn the concepts of Node.js to gain a high-level understanding of the Node.js execution model
  • Build an interactive web application with MongoDB and Redis and create your own JavaScript modules that work both on the client side and server side
  • Familiarize yourself with the new features of Node.js and JavaScript with this exclusive step-by-step guide

Description

Node.js is an open source, cross-platform runtime environment that allows you to use JavaScript to develop server-side web applications. This short guide will help you develop applications using JavaScript and Node.js, leverage your existing programming skills from .NET or Java, and make the most of these other platforms through understanding the Node.js programming model. You will learn how to build web applications and APIs in Node, discover packages in the Node.js ecosystem, test and deploy your Node.js code, and more. Finally, you will discover how to integrate Node.js and .NET code.

Who is this book for?

This book is for developers who want to learn JavaScript and Node.js. Previous experience with programming is desired, but no JavaScript or Node.js knowledge is required. The book focuses mostly on web development, such as networking, serving dynamic pages, and real-time client-server communication.

What you will learn

  • Understand which problems Node.js best solves
  • Write idiomatic JavaScript and Node.js code
  • Build web applications and command-line tools
  • Minimise complexity and efficiently solve difficult problems
  • Test and deploy Node.js applications
  • Work with persistent data
  • Implement real-time client-server applications
  • Integrate .NET and Node.js code

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 24, 2016
Length: 248 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287510
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jun 24, 2016
Length: 248 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287510
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just NZ$7 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just NZ$7 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total NZ$ 201.97
JavaScript for .NET Developers
NZ$80.99
Learning Node.js for .NET  Developers
NZ$48.99
Reactive Programming for .NET Developers
NZ$71.99
Total NZ$ 201.97 Stars icon
Banner background image

Table of Contents

15 Chapters
1. Why Node.js? Chevron down icon Chevron up icon
2. Getting Started with Node.js Chevron down icon Chevron up icon
3. A JavaScript Primer Chevron down icon Chevron up icon
4. Introducing Node.js Modules Chevron down icon Chevron up icon
5. Creating Dynamic Websites Chevron down icon Chevron up icon
6. Testing Node.js Applications Chevron down icon Chevron up icon
7. Setting up an Automated Build Chevron down icon Chevron up icon
8. Mastering Asynchronicity Chevron down icon Chevron up icon
9. Persisting Data Chevron down icon Chevron up icon
10. Creating Real-time Web Apps Chevron down icon Chevron up icon
11. Deploying Node.js Applications Chevron down icon Chevron up icon
12. Authentication in Node.js Chevron down icon Chevron up icon
13. Creating JavaScript Packages Chevron down icon Chevron up icon
14. Node.js and Beyond Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(2 Ratings)
5 star 0%
4 star 100%
3 star 0%
2 star 0%
1 star 0%
Gary A. Miller Jul 30, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Looks like it's covering all of the topics I thought it would.The one exception is Visual Studio. I wish it covered Node.js development using Visual Studio more thoroughly.
Amazon Verified review Amazon
Go Edmonton Oct 04, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Not sure about the "for .Net developers" was proper or not though.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.