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

@siberiacancode/lockparse

v0.0.3

Published

A lightweight zero-dependency lockfile parser with version-range preservation, rich tree traversal, and dependency intelligence (npm, e18e, CVE).

Readme

🔒 lockparse

A lightweight zero-dependency lockfile parser for npm, Yarn, pnpm, and Bun.

Installation

npm install @siberiacancode/lockparse

Usage

import { parse } from '@siberiacancode/lockparse';
import { readFile } from 'node:fs/promises';

const content = await readFile('./package-lock.json', 'utf-8');
const lockfile = parse(content, 'package-lock.json');

console.log(lockfile.root.dependencies);

Supported lockfiles

The parser supports the most common JavaScript package manager lockfiles:

parse(npmLock, 'npm');
parse(npmLock, 'package-lock.json');

parse(yarnLock, 'yarn');
parse(yarnLock, 'yarn.lock', packageJson);

parse(pnpmLock, 'pnpm');
parse(pnpmLock, 'pnpm-lock.yaml');

parse(bunLock, 'bun');
parse(bunLock, 'bun.lock');

Dependency graph

Each parsed lockfile contains the lockfile type, a root dependency node, and a flat package list.

const lockfile = parse(content, 'pnpm-lock.yaml');

lockfile.type; // 'pnpm'
lockfile.root; // root ParsedDependency
lockfile.packages; // ParsedDependency[]

Dependency nodes include regular dependency arrays and a requires list with rich edges:

const [dependency] = lockfile.root.dependencies;

dependency.name;
dependency.version;
dependency.dependencies;
dependency.devDependencies;
dependency.peerDependencies;
dependency.optionalDependencies;
dependency.requires;

Version ranges

Every dependency edge preserves the original requested range where the lockfile contains it.

const [edge] = lockfile.root.requires;

edge.from; // parent dependency node
edge.node; // child dependency node
edge.type; // 'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies'
edge.range?.raw; // '^1.2.0'
edge.range?.operator; // '^'
edge.range?.version; // '1.2.0'
edge.range?.exact; // false

Serialization

Parsed dependency graphs contain shared references and circular edges. Use serializeLockFile or stringifyLockFile when you need JSON-safe output.

import { parse, stringifyLockFile } from '@siberiacancode/lockparse';

const lockfile = parse(content, 'package-lock.json');
const json = stringifyLockFile(lockfile, 2);

You can include dependency provenance with the via option:

const json = stringifyLockFile(lockfile, 2, { via: true });

Deserialization

Serialized lockfiles can be turned back into the in-memory dependency graph.

import { parseLockFileJson } from '@siberiacancode/lockparse';

const lockfile = parseLockFileJson(json);

Indexing

Use indexNodes to get every reachable node once and stable ids for graph references.

import { indexNodes, parse } from '@siberiacancode/lockparse';

const lockfile = parse(content, 'bun.lock');
const { nodes, ids } = indexNodes(lockfile);

nodes.length;
ids.get(lockfile.root);