22 amazing 🤯 NPM packages you should Try
Tags: webdev, javascript, beginners, npm
Published: 2024-07-04 21:35:59


1. **chalk**
    - **Description**: Style your terminal output with colors and styles.
    - **Example**:
        
        ```jsx
        const chalk = require('chalk');
        console.log(chalk.blue('Hello world!'));
        
        ```
        
    
2. **figlet**
    - **Description**: Create ASCII art text in the terminal.
    - **Example**:
        
        ```jsx
        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**:
        
        ```jsx
        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**:
        
        ```jsx
        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**:
        
        ```jsx
        const randomColor = require('randomcolor');
        const color = randomColor();
        console.log(color);
        
        ```
        
6. **faker**
    - **Description**: Generate massive amounts of fake data.
    - **Example**:
        
        ```jsx
        const faker = require('faker');
        console.log(faker.name.findName());
        
        ```
        
7. **axios**
    - **Description**: Promise-based HTTP client for the browser and Node.js.
    - **Example**:
        
        ```jsx
        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**:
        
        ```jsx
        const moment = require('moment');
        console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
        
        ```
        
9. **boxen**
    - **Description**: Create boxes in the terminal.
    - **Example**:
        
        ```jsx
        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**:
        
        ```jsx
        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**:
        
        ```jsx
        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**:
        
        ```jsx
        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**:
        
        ```jsx
        require('dotenv').config();
        console.log(process.env.DB_HOST);
        
        ```
        
14. **crypto-random-string**
    - **Description**: Generate a cryptographically strong random string.
    - **Example**:
        
        ```jsx
        const cryptoRandomString = require('crypto-random-string');
        console.log(cryptoRandomString({ length: 10 }));
        
        ```
        
15. **ascii-art**
    - **Description**: Generate ASCII art from text.
    - **Example**:
        
        ```jsx
        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**:
        
        ```jsx
        const emoji = require('node-emoji');
        console.log(emoji.get('coffee'));
        
        ```
        
17. **is-online**
    - **Description**: Check if the internet connection is available.
    - **Example**:
        
        ```jsx
        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**:
        
        ```jsx
            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**:
        
        ```jsx
        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**:
    
        ```jsx
        javascriptCopy code
        const beeper = require('beeper');
        beeper();
    
        ```
    
21. **funny-quotes**
    - **Description**: fetches random funny quotes.
    - **Example**:
        
        ```jsx
        javascriptCopy code
        const funnyQuotes = require('funny-quotes');
        console.log(funnyQuotes.getRandomQuote());
        
        ```
        
22. **random-puppy**
    - **Description**: fetches random puppy pictures from Reddit.
    - **Example**:
        
        ```jsx
        javascriptCopy code
        const randomPuppy = require('random-puppy');
        randomPuppy()
            .then(url => console.log(url))
            .catch(err => console.error(err));
        
        ```