/node-npm

Primary LanguageJavaScriptOtherNOASSERTION

General Assembly Logo

Using NPM with Node

Prerequisites

Objectives

By the end of this, developers should be able to:

  • Find an NPM package that solves a common problem.
  • Write a script that uses an NPM package.

Preparation

  1. Fork and clone this repository.
  2. Install dependencies with npm install.

Node and NPM

  • Node modules
  • Modules available through NPM

Demo: Install a Package for Enumeration

  • Ruby was really convenient for list processing
  • How can we do something similar in Node?

Lab: Research Popular NPM Packages

Find the most popular packages on NPM and note, in your own words, three of the packages. Questions to consider while you research:

  1. What problem does this package solve?
  2. How can I use this package in my own code? What steps are involved?
  3. How well maintained is this package? What criteria did I use to decide?

Lab: Use Packages in randomizer.js

Take your randomizer script from ga-wdi-boston/node-api. Change it to use packages from NPM. You will need to identify what code you want to replace with a package and then find an appropriate package using Google or the NPM registry.

Here are a few things you might try:

  • Use lodash to iterate through collections.
  • Find a randomizer package to randomly sort an array.
  • Find a package to colorize terminal output and make your output pretty.
  • Decorate your output with emojis!

Useful NPM Packages

Careful when using packages in your font-end projects. Some of them are very large!

Additional Resources

Source code distributed under the MIT license. Text and other assets copyright General Assembly, Inc., all rights reserved.