npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

easy-console-colors

v0.1.1

Published

Easily add colors to your console

Readme

easy-console-colors

Add colors to your console with 2 lines of code.

import {enableConsoleColors} from 'easy-console-colors';

or

const {enableConsoleColors} = require('easy-console-colors');
enableConsoleColors();

console.log("Log", "a", "b");
console.info("Info", "a", "b");
console.warn("Warning", "a", "b");
console.error("Error", "a", "b");

Once enabled all console logs accross the process will be colorized. You need to restart the process if you want to disable.

Default values

const defaultLogs = {
    log:   {prefix: '', color: colors.Reset,    suffix: ''},
    info:  {prefix: '', color: colors.FgGreen,  suffix: ''},
    warn:  {prefix: '', color: colors.FgYellow, suffix: ''},
    error: {prefix: '', color: colors.FgRed,    suffix: ''}
}
  • prefix and suffix: prepend and append a string to the log value. The color won't be applied to these values, you can contatenate a color to the string.
  • color: An ansi color code as string or a function that will apply a color to the log value (i.e. chalk).

Customization

If you don't like default colors or you want to customize the format of your logs, you can override defaults.

import {enableConsoleColors, colors} from 'easy-console-colors';

enableConsoleColors({enabled: true,
    logs: {
        log: {prefix: `[${new Date().toLocaleString()}]`,  suffix: `***`},
        warn: {color: colors.FgCyan},
    }
});

Above configuration will:

  • Override 'log' to prepend date string like [8/12/2020, 10:24:55 AM] and append '***' to the log string.
  • Override 'warn' to print messages in cyan instead of yellow.

You can also use default values as base and customize them to your needs.

import {enableConsoleColors, colors, defaultLogs} from 'easy-console-colors';

const {log, warn} = defaultLogs;
log.color = colors.FgBlue;

const logs = { log };

Above configuration will:

  • Override 'log' color to be blue.

Disable for production environment

enableConsoleColors({enabled: process.env.NODE_ENV !== "production"});

Profiles

You can define some kind of profiles to quickly switch between them.

const getTimestamp = () => `${colors.FgCyan}[${new Date().toLocaleString()}]`;

const consoleProfiles = {
    default: defaultLogs,
    timestamp: {
        log:   {prefix: getTimestamp(), color: colors.Reset    },
        info:  {prefix: getTimestamp(), color: colors.FgGreen  },
        warn:  {prefix: getTimestamp(), color: colors.FgYellow },
        error: {prefix: getTimestamp(), color: colors.FgRed    }
    },
    chalk: {
        info: {
            prefix: chalk.hex('#a87332')(`[${new Date().toLocaleString()}]`),
            color: chalk.keyword('orange')
        }
    }
}

enableConsoleColors({enabled: true, logs: consoleProfiles.timestamp});

Additional colors

easy-console-colors includes basic ansi colors, but you can use 3rd party tools like chalk to customize your logs.

enableConsoleColors({enabled: true,
    logs: {
        info: {prefix: chalk.hex('#a87332')(`[${new Date().toLocaleString()}]`),
        color: chalk.keyword('orange')}
    }
});