Book Image

Learn TypeScript 3 by Building Web Applications

By : Sebastien Dubois, Alexis Georges
Book Image

Learn TypeScript 3 by Building Web Applications

By: Sebastien Dubois, Alexis Georges

Overview of this book

TypeScript is a superset of the JavaScript programming language, giving developers a tool to help them write faster, cleaner JavaScript. With the help of its powerful static type system and other powerful tools and techniques it allows developers to write modern JavaScript applications. This book is a practical guide to learn the TypeScript programming language. It covers from the very basics to the more advanced concepts, while explaining many design patterns, techniques, frameworks, libraries and tools along the way. You will also learn a ton about modern web frameworks like Angular, Vue.js and React, and you will build cool web applications using those. This book also covers modern front-end development tooling such as Node.js, npm, yarn, Webpack, Parcel, Jest, and many others. Throughout the book, you will also discover and make use of the most recent additions of the language introduced by TypeScript 3 such as new types enforcing explicit checks, flexible and scalable ways of project structuring, and many more breaking changes. By the end of this book, you will be ready to use TypeScript in your own projects and will also have a concrete view of the current frontend software development landscape.
Table of Contents (15 chapters)

Updating npm

Updating npm is not always as straightforward as it should be, so let us cover this subject, at least for Windows and Linux.

Linux

On Linux, updating npm is very straightforward; just execute the following command:

npm install --global npm@latest

This single command will update npm for you.

Windows

On Windows, updating npm is trickier. The issue on Windows is that npm is installed along with Node.js and if you simply try the same approach as for Linux, the new version of npm that you download will always be shadowed by the one coming with node itself. This is due to the order of the entries in your PATH environment variables.

One workaround consists in changing the order of the path entries. Another one is to avoid installing npm when you install node. This lets you install and upgrade npm separately. That also comes with its hassles, though.

Instead, here's a simple solution, using the npm-windows-upgrade (https://github.com/felixrieseberg/npm-windows-upgrade) utility. To use it, open up a Windows shell (that is, cmd.exe) as administrator then execute the following commands:

  • npm install -g npm-windows-upgrade
  • npm-windows-upgrade

You'll be asked to select the version of npm that you want to install. In the proposed list, select a version that is greater than and equal to 6.4.1. Once the upgrade is completed, you should be able to use the new npm version directly! If you're curious about what changed in the npm cli, check out the official release notes: https://github.com/npm/cli/releases.

Note that there are other solutions such as nvm-windows (https://github.com/coreybutler/nvm-windows) that we won't be covering here.