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

workspace-tutorial

v1.0.1

Published

## TLDR;

Readme

Lerna tutorial

TLDR;

  • npm install (installs lerna)

  • lerna bootstrap (connects all the packages)

  • npm -C ./packages/usage run start (console logs "alpha" and "beta" from combind use example module)

  • Tree Structure

  • packages

    • alpha (deps: [])
    • beta (deps: [])
    • usage (deps: ["alpha", "beta"])

Summary

First off, What is lerna? lerna is a tool that allows you to maintain multiple npm packages within one repository.

There's a couple of benefits to this kind of approach, the paradigm is called a monorepo, and more can be read about it from the source of babel, and react.

Here's the gist:

  • Single lint, build, test and release process.
  • Easy to coordinate changes across modules.
  • Single place to report issues.
  • Easier to setup a development environment.
  • Tests across modules are ran together which finds bugs that touch multiple modules easier.

Getting started.

For this demo I'm going to be using [email protected]. lerna is a CLI (command line interface) tool. You're going to want to install it with the --global (-g) flag.

npm i [email protected] -g

Then once it's done installing your going to want to run the following

mkdir my-monorepo && cd $_ && lerna init

This will do a couple of things.

  • Creating packages folder.
  • Updating package.json.
  • Creating lerna.json.

The /packages folder is where all of your packages belong. Let's go about making a new package alpha.

cd packages
mkdir alpha
cd alpha
npm init -y
echo "module.exports = 'alpha'" > index.js

Lets go through the same steps for another package beta.

First go up one directory:

cd ..

Now go about creating beta.

mkdir beta
cd beta
npm init -y
echo "module.exports = 'beta'" > index.js

Now we're going to create a usage package that uses both alpha and beta as dependencies.

First go up one directory:

cd ..

Now go about creating \usage.

mkdir usage
cd usage
npm init -y
touch index.js

Open up /packages/usage/index.js in a text editor and paste this in.

var alpha = require('alpha')
var beta = require('beta')
console.log(alpha + " " + beta)

We're almost there. At this point your whole project should look something like this:

.
├── README.md
├── lerna.json
├── package.json
└── packages
    ├── alpha
    │   ├── index.js
    │   └── package.json
    ├── beta
    │   ├── index.js
    │   └── package.json
    └── usage
        ├── index.js
        └── package.json

What you want to do now is go into /packages/usage/package.json and add these lines under dependencies.

{
  "dependencies": {
    "alpha": "1.0.0",
    "beta": "1.0.0"  
  }
}

Now you need to wire everything up with this command.

lerna bootstrap

The output from this command should look something like this:

Lerna v2.0.0-beta.20
Linking all dependencies
Successfully bootstrapped 3 packages.

Now using the tree command once more (brew install tree) we can see the folder structure we can see what lerna did.

.
├── README.md
├── lerna.json
├── package.json
└── packages
    ├── alpha
    │   ├── index.js
    │   ├── node_modules
    │   └── package.json
    ├── beta
    │   ├── index.js
    │   ├── node_modules
    │   └── package.json
    └── usage
        ├── index.js
        ├── node_modules
        │   ├── alpha
        │   │   ├── index.js
        │   │   └── package.json
        │   └── beta
        │       ├── index.js
        │       └── package.json
        └── package.json

It added two stubbed (my term not lerna's) modules. If you peak inside /packages/usage/node_modules/alpha/index.js you can see what I mean.

contents of ./packages/usage/node_modules/alpha/index.js

module.exports = require("/Users/thomas/Desktop/lerna-tutorial/packages/alpha");

Note: This is an absolute path to the module. So if you ever move your lerna project you'll need to rerun lerna bootstrap.

And volia! When we run node ./packages/usage/index.js we get our expected output!

alpha beta