DEV Community

Cover image for 22 amazing 🤯 NPM packages you should Try
Rajveer
Rajveer

Posted on

22 amazing 🤯 NPM packages you should Try

  1. chalk

    • Description: Style your terminal output with colors and styles.
    • Example:

      const chalk = require('chalk'); console.log(chalk.blue('Hello world!')); 
  2. figlet

    • Description: Create ASCII art text in the terminal.
    • Example:

      const figlet = require('figlet'); figlet('Hello World!', function(err, data) { if (err) { console.log('Something went wrong...'); console.dir(err); return; } console.log(data); }); 
  3. ora

    • Description: Elegant terminal spinner.
    • Example:

      const ora = require('ora'); const spinner = ora('Loading unicorns').start(); setTimeout(() => { spinner.color = 'yellow'; spinner.text = 'Loading rainbows'; }, 1000); 
  4. inquirer

    • Description: Interactive command-line user interface.
    • Example:

      const inquirer = require('inquirer'); inquirer.prompt([ { type: 'input', name: 'name', message: "What's your name?" } ]).then(answers => { console.log(`Hello, ${answers.name}!`); }); 
  5. randomcolor

    • Description: Generate attractive random colors.
    • Example:

      const randomColor = require('randomcolor'); const color = randomColor(); console.log(color); 
  6. faker

    • Description: Generate massive amounts of fake data.
    • Example:

      const faker = require('faker'); console.log(faker.name.findName()); 
  7. axios

    • Description: Promise-based HTTP client for the browser and Node.js.
    • Example:

      const axios = require('axios'); axios.get('<https://jsonplaceholder.typicode.com/posts/1>') .then(response => console.log(response.data)) .catch(error => console.error(error)); 
  8. moment

    • Description: Parse, validate, manipulate, and display dates and times.
    • Example:

      const moment = require('moment'); console.log(moment().format('MMMM Do YYYY, h:mm:ss a')); 
  9. boxen

    • Description: Create boxes in the terminal.
    • Example:

      const boxen = require('boxen'); console.log(boxen('Hello, Box!', { padding: 1 })); 
  10. node-fetch

    • Description: A lightweight module that brings window.fetch to Node.js.
    • Example:

      const fetch = require('node-fetch'); fetch('<https://jsonplaceholder.typicode.com/posts/1>') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)); 
  11. lodash

    • Description: A modern JavaScript utility library delivering modularity, performance, & extras.
    • Example:

      const _ = require('lodash'); const array = [1, 2, 3, 4, 5]; console.log(_.shuffle(array)); 
  12. node-notifier

    • Description: A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback).
    • Example:

      const notifier = require('node-notifier'); notifier.notify({ title: 'My Notification', message: 'Hello, there!' }); 
  13. dotenv

    • Description: Loads environment variables from a .env file into process.env.
    • Example:

      require('dotenv').config(); console.log(process.env.DB_HOST); 
  14. crypto-random-string

    • Description: Generate a cryptographically strong random string.
    • Example:

      const cryptoRandomString = require('crypto-random-string'); console.log(cryptoRandomString({ length: 10 })); 
  15. ascii-art

    • Description: Generate ASCII art from text.
    • Example:

      const ascii = require('ascii-art'); ascii.font('Hello World!', 'Doom', function(rendered) { console.log(rendered); }); 
  16. node-emoji

    • Description: Simple emoji support for Node.js projects.
    • Example:

      const emoji = require('node-emoji'); console.log(emoji.get('coffee')); 
  17. is-online

    • Description: Check if the internet connection is available.
    • Example:

      javascriptCopy code const isOnline = require('is-online'); isOnline().then(online => { console.log(online ? 'Online' : 'Offline'); }); 
  18. number-to-words

    • Description: Convert numbers to words.
    • Example:

       javascriptCopy code const numberToWords = require('number-to-words'); console.log(numberToWords.toWords(123)); 
  19. nodemailer

    • Description: It is a module for sending emails from Node.js applications.
    • Example:

      javascriptCopy code const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'your-email@gmail.com', pass: 'your-password' } }); const mailOptions = { from: 'your-email@gmail.com', to: 'recipient@example.com', subject: 'Sending Email using Node.js', text: 'Hello from Node.js!' }; transporter.sendMail(mailOptions, function(error, info) { if (error) { console.error(error); } else { console.log('Email sent: ' + info.response); } 
  20. beeper

    • Description: makes your terminal beep.
    • Example:

      javascriptCopy code const beeper = require('beeper'); beeper(); 
  21. funny-quotes

    • Description: fetches random funny quotes.
    • Example:

      javascriptCopy code const funnyQuotes = require('funny-quotes'); console.log(funnyQuotes.getRandomQuote()); 
  22. random-puppy

    • Description: fetches random puppy pictures from Reddit.
    • Example:

      javascriptCopy code const randomPuppy = require('random-puppy'); randomPuppy() .then(url => console.log(url)) .catch(err => console.error(err)); 

Top comments (0)