Search icon CANCEL
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
Angular 6 for Enterprise-Ready Web Applications

You're reading from   Angular 6 for Enterprise-Ready Web Applications Deliver production-ready and cloud-scale Angular web apps

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781786462909
Length 512 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Doguhan Uluca Doguhan Uluca
Author Profile Icon Doguhan Uluca
Doguhan Uluca
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Setting Up Your Development Environment 2. Create a Local Weather Web Application FREE CHAPTER 3. Prepare Angular App for Production Release 4. Staying Up to Date with Angular Updates 5. Enhance Angular App with Angular Material 6. Reactive Forms and Component Interaction 7. Create a Router-First Line-of-Business App 8. Continuous Integration and API Design 9. Design Authentication and Authorization 10. Angular App Design and Recipes 11. Highly-Available Cloud Infrastructure on AWS 12. Google Analytics and Advanced Cloud Ops 13. Other Books You May Enjoy

Node.js

This section aims to establish a best practice JavaScript development environment. To make the best use of this book, it is presumed that you have the following prerequisites fulfilled:

Node.js is JavaScript that runs anywhere. It's an open source project that aimed to run JavaScript on the server, built on Google Chrome's V8 JavaScript engine. In late 2015, Node.js stabilized and announced enterprise-friendly 18 month LTS cycles that brought predictability and stability to the platform, paired with a more frequently updated, but more experimental, Latest branch. Node also ships bundled with npm, the Node package manager, and as of 2018, npm is the largest repository of JavaScript packages in the world.

For a more detailed look into Node's history, read my two-part article on Node at: Bit.ly/NodeJSHistory.

You may have heard of yarn and how it's faster or better than npm. As of npm 5, which ships bundled with Node 8, npm is more feature rich, easier to use and on par with yarn in terms of performance. Yarn is published by Facebook, which also created the React JavaScript UI library. It must be noted that yarn relies on the npm repository, so whichever tool you use, you get access to the same library of packages.

Existing Node.js Installation

If you installed Node.js before, when installing a new version of Node using choco or brew, ensure that you read the command outputs carefully. Your package manager may return caveats or additional instructions to follow, so you can successfully complete the installation.

It is also highly likely that your system or folder permissions have been edited manually in the past, which may interfere with a frustration-free operation of Node. If the following commands do not resolve your issues, use the GUI installer from Node's site as a last resort.

Regardless, you must take care to uninstall all global tools that were installed using npm -g previously. With every major Node version, there's a chance that native bindings between your tool and Node have been invalidated. Further, global tools rapidly fall out of date and project-specific tools quick go out of sync. As a result, installing tools globally is now an anti-pattern that has been replaced with better techniques, which are covered in the next section and under the Angular CLI section in Chapter 2, Create a Local Weather Web Application.

To see a list of your globally install packages, execute npm list -g --depth 0. To uninstall a global package, execute npm uninstall -g package-name. I would recommend that you uninstall all globally installed packages and restart from scratch with the suggestions provided in the next section.

Installing Node.js

This book will presume that you're using Node 8.4 or a later version. Odd numbered versions of Node are not meant to be long lived. 6.x.x, 8.x.x, 10.x.x, and so on are okay, but avoid 7.x.x, 9.x.x, and so on, at all costs.

  1. Execute the installation command:

For Windows:

PS> choco install nodejs-lts -y

For macOS:

$ brew install node@8
  1. Verify installation of Node by executing node -v
  2. Verify npm by executing npm -v
Note that you should never upgrade your npm version using npm install -g npm on Windows, as highlighted in Chapter 4, Staying Up to Date with Angular Updates. It is highly recommended that you use the npm-windows-upgrade npm package.

The npm repository contains numerous useful and mature CLI commands that are often cross-platform. Listed here are the ones I rely on frequently and choose to install globally for performance reasons:

  • npx: Executes CLI tools by downloading the latest version on demand or project-specific local node_modules folder. It ships with npm 5 and will allow you to run code generators that frequently update without a global install.
  • rimraf: The Unix command rm -rf, but works on Windows as well. Very useful in deleting the node_modules folder, especially when Windows is unable to do so due to the nested folder structure.
  • npm-update: Analyzes your project folder and reports on which package have newer versions or not, with the option to be able to update all of them, if you so wish.
  • n: Dead easy to tool to switch between versions of Node quickly, without having to remember the specific version number. Unfortunately, it only works on macOS/Linux.
  • http-server: Simple, zero-configuration command-line HTTP server, which is a great way to locally test static HTML/CSS pages or even the dist folder of your Angular or React project.
  • npm-windows-upgrade: Necessary to upgrade npm on Windows.
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