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

ts-lock-scanner

v0.1.0

Published

Validate npm/yarn lockfiles against remotely hosted bad-version ranges

Downloads

10

Readme

ts-lock-scanner — TypeScript package

ts-lock-scanner is a library and CLI tool for validating yarn.lock and package-lock.json files against known vulnerable or malicious dependencies. The list of bad version ranges is fetched from a remote URL, making updates easy.


Russian version / Русская версия

Features

  • 🚨 Validate yarn.lock (Yarn v1 and Berry v2/3).
  • 🚨 Validate package-lock.json (npm v6+).
  • 🌐 Fetch list of vulnerable version ranges from the network (configurable URL or environment variable BAD_MODULES_URL).
  • ✅ Deduplication: each package version is reported only once, even if it appears in multiple places.
  • 🧩 Separate functions for npm and yarn — usable as a library.
  • 📦 CLI interface for quick scanning.
  • 🔧 Supports semver ranges (>=, <, ^, etc.).

Installation

npm install ts-lock-scanner --save-dev
# or
pnpm add -D ts-lock-scanner
# or
yarn add -D ts-lock-scanner

Build (if working from source):

npm run build

Usage (CLI)

# Set the URL of the bad-ranges JSON
export BAD_MODULES_URL="https://your.cdn/bad-packages.json"

# Check yarn.lock
npx ts-lock-scanner ./yarn.lock

# Check package-lock.json
npx ts-lock-scanner ./package-lock.json

# Provide URL explicitly
npx ts-lock-scanner ./yarn.lock --url https://your.cdn/bad-packages.json

Example bad-packages.json:

{
  "chalk": ">=5.6.1 <5.6.3",
  "ansi-regex": ">=6.2.1",
  "debug": ">=4.4.2 <4.4.3"
}

Usage (as a library)

import { fetchBadRanges, scanYarnLock, scanPackageLock } from "ts-lock-scanner";
import { readFileSync } from "fs";

// Load bad ranges
const bad = await fetchBadRanges({ url: "https://your.cdn/bad-packages.json" });

// Validate yarn.lock
const yarnText = readFileSync("./yarn.lock", "utf8");
const yarnResult = scanYarnLock(yarnText, bad);
console.log(yarnResult.hits);

// Validate package-lock.json
const npmText = readFileSync("./package-lock.json", "utf8");
const npmResult = scanPackageLock(npmText, bad);
console.log(npmResult.hits);

Types

  • fetchBadRanges({ url? })Promise<BadRangeMap> — loads a map { packageName: semverRange }.
  • scanYarnLock(text, badMap)ScanResult.
  • scanPackageLock(text, badMap)ScanResult.
  • ScanResult contains hits: Hit[].
  • Hit = { name, version, ranges[], from? }.

Recommendations when vulnerabilities are found

  • Pin safe versions (<= minimum vulnerable − 1).

  • Clear cache:

    yarn cache clean
    npm cache clean --force
  • Fully reinstall dependencies.


Requirements

  • Node.js >=18 (uses built-in fetch).
  • Compatible with TypeScript 5.x.

License

MIT