Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Node.js: Tools & Skills
Node.js: Tools & Skills
Node.js: Tools & Skills
Ebook181 pages1 hour

Node.js: Tools & Skills

Rating: 0 out of 5 stars

()

Read preview

About this ebook

While there have been quite a few attempts to get JavaScript working as a server-side language, Node.js (frequently just called Node) has been the first environment that's gained any traction. It's now used by companies such as Netflix, Uber and Paypal to power their web apps. Node allows for blazingly fast performance; thanks to its event loop model, common tasks like network connection and database I/O can be executed very quickly indeed.

In this book, we'll take a look at a selection of the related tools and skills that will make you a much more productive Node developer. It contains:

  1. Installing Multiple Versions of Node.js Using nvm
  2. A Beginner's Guide to npm
  3. Create New Express.js Apps in Minutes with Express Generator
  4. An Introduction to AdonisJs, a Laravel-like Node.js Framework
  5. Top 5 Developer-friendly Node.js API Frameworks
  6. Using MySQL with Node.js and the mysql JavaScript Client
  7. Introduction to MongoDB
LanguageEnglish
PublisherSitePoint
Release dateApr 24, 2020
ISBN9781098122843
Node.js: Tools & Skills
Author

James Hibbard

I'm a web developer currently living in the sunny north of Germany. I enjoy coding in both JavaScript and Ruby and can often be found in SitePoint's JavaScript forum. When I'm not coding, I enjoy running.

Read more from James Hibbard

Related to Node.js

Related ebooks

Programming For You

View More

Related articles

Reviews for Node.js

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Node.js - James Hibbard

    Preface

    While there have been quite a few attempts to get JavaScript working as a server-side language, Node.js (frequently just called Node) has been the first environment that's gained any traction. It's now used by companies such as Netflix, Uber and Paypal to power their web apps. Node allows for blazingly fast performance; thanks to its event loop model, common tasks like network connection and database I/O can be executed very quickly indeed.

    In this book, we'll take a look at a selection of the related tools and skills that will make you a much more productive Node developer.

    Who Should Read This Book?

    This book is for anyone who wants to start learning server-side development with Node.js. Familiarity with JavaScript is assumed, but we don't assume any previous back-end development experience.

    Conventions Used

    Code Samples

    Code in this book is displayed using a fixed-width font, like so:

    A Perfect Summer's Day

    It was a lovely day for a walk in the park.

    The birds were singing and the kids were all back at school.

    Where existing code is required for context, rather than repeat all of it, ⋮ will be displayed:

    function animate() {

        ⋮

    new_variable = Hello;

     

    }

    Some lines of code should be entered on one line, but we’ve had to wrap them because of page constraints. An ➥ indicates a line break that exists for formatting purposes only, and should be ignored:

    URL.open("http://www.sitepoint.com/responsive-web-

    ➥design-real-user-testing/?responsive1");

    You’ll notice that we’ve used certain layout styles throughout this book to signify different types of information. Look out for the following items.

    Tips, Notes, and Warnings

    Hey, You!

    Tips provide helpful little pointers.

    Ahem, Excuse Me ...

    Notes are useful asides that are related—but not critical—to the topic at hand. Think of them as extra tidbits of information.

    Make Sure You Always ...

    ... pay attention to these important points.

    Watch Out!

    Warnings highlight any gotchas that are likely to trip you up along the way.

    Supplementary Materials

    https://www.sitepoint.com/community/ are SitePoint’s forums, for help on any tricky problems.

    books@sitepoint.com is our email address, should you need to contact us to report a problem, or for any other reason.

    Chapter 1: Installing Multiple Versions of Node.js Using nvm

    by Michael Wanyoike and James Hibbard

    When working with Node.js, you might encounter situations where you need to install multiple versions of the runtime.

    For example, maybe you have the latest version of Node set up on your machine, yet the project you’re about to start working on requires an older version. Or maybe you’re upgrading an old Node project to a more modern version and it would be handy to be able to switch between the two while you make the transition.

    Without a good tool, this would mean spending a lot of time and effort manually uninstalling and reinstalling Node versions and their global packages. Fortunately, there’s a better way!

    Introducing nvm

    nvm stands for Node Version Manager. As the name suggests, it helps you manage and switch between different Node versions with ease. It provides a command-line interface where you can install different versions with a single command, set a default, switch between them and much more.

    OS Support

    nvm supports both Linux and macOS, but that’s not to say that Windows users have to miss out. There’s a second project named nvm-windows that offers Windows users the option of easily managing Node environments. Despite the name, nvm-windows is not a clone of nvm, nor is it affiliated with it. However, the basic commands listed below (for installing, listing and switching between versions) should work for both nvm and nvm-windows.

    Installation

    Let’s first cover installation for Windows, macOS and Linux.

    Windows

    First, we need to do a little preparation:

    uninstall any existing versions of Node.js

    delete any existing Node.js installation directories (such as C:\Program Files\nodejs)

    delete the existing npm install location (such as C:\Users\\AppData\Roaming\npm)

    After this, download and run the latest stable installer and you should be good to go!

    macOS/Linux

    Unlike Windows, removing previous Node and npm installations in macOS and Linux is optional. If this is something you want to do, there are plenty of good resources available online. For example, here’s how to remove Node on macOS and on Linux. And here’s how you can remove any previous npm installation you might have.

    You can install nvm using cURL or Wget. On your terminal, run the following:

    With cURL:

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash

    Or with Wget:

    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash

    Note that the version number (v0.35.2) will change as the project develops, so it’s worth checking the relevant section of project’s home page to find the most recent version.

    This will clone the nvm repository to ~/.nvm and will make the required changes to your bash profile, so that nvm is available from anywhere in your terminal.

    And that’s it! Reload (or restart) your terminal and nvm is ready to be used.

    Using nvm

    If installed correctly, the nvm command is available anywhere in you terminal. Let’s see how to use it to manage Node.js versions.

    Install Multiple Versions of Node.js

    One of the most important parts of nvm is, of course, installing different versions of Node.js. For this, nvm provides the nvm install command. You can install specific versions by running this command followed by the version you want. For example:

    nvm install 12.14.1

    By running the above in a terminal, nvm will install Node.js version 12.14.1.

    Running nvm use

    nvm-windows users will have to run nvm use 12.14.1 after installing.

    nvm follows SemVer, so if you want to install, for example, the latest 12.14 patch, you can do it by running:

    nvm install 12.14

    nvm will then install Node.js version 12.14.X, where X is the highest available version. At the time of writing, this is 1, so you’ll have the 12.14.1 version installed on your system.

    You can see the full list of available

    Enjoying the preview?
    Page 1 of 1