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

@smarlhens/npm-pin-dependencies

v1.0.1

Published

Pin dependency ranges in package.json to the exact versions resolved by the lockfile

Downloads

409

Readme

NPM pin dependencies

CI napi-npd node-current (scoped) license Conventional Commits

npm-pin-dependencies pins your package.json dependency ranges to the exact versions resolved by the lockfile.

This package ships a native Rust core via NAPI-RS as part of the riri-node-tools monorepo.


Table of Contents


Prerequisites

  • Node.js version ^22.22.2 || ^24.15.0 || >=26.0.0

Supported platforms:

| OS | Arch | | ------- | ------------------------------------ | | Linux | x64 (glibc/musl), arm64 (glibc/musl) | | macOS | x64, arm64 | | Windows | x64 |


Installation

Install globally:

npm install -g @smarlhens/npm-pin-dependencies

Or run with npx:

npx @smarlhens/npm-pin-dependencies

Usage

CLI

Show which package.json dependency ranges would be pinned to lockfile-resolved versions:

npd

Sample output (against fixtures/npd-npm-v3-unpinned-deps):

    bar  ~18.2.0   →  18.2.0
    foo  ^4.17.21  →  4.17.21
    baz  ^1.0.0    →  1.6.0

  Run npd -u to upgrade package.json.

Apply the pins to package.json:

npd -u

Emit machine-readable JSON:

npd --json

Supports package-lock.json, yarn.lock, and pnpm-lock.yaml (auto-detected).

Node API

import { pinDependencies } from '@smarlhens/npm-pin-dependencies';

const packageJson = '...'; // stringified package.json
const lockfileContent = '...'; // stringified lockfile

const { pins } = pinDependencies({
  packageJson,
  lockfileContent,
  lockfileType: 'npm', // optional: 'npm' | 'yarn' | 'pnpm' — auto-detected when omitted
});

for (const { name, kind, from, to } of pins) {
  console.log(`${kind} ${name}: "${from}" → "${to}"`);
}

runCli(argv) is also exported to run the npd CLI in-process; argv[0] must be the program name. Returns exit code.


Options

Pin range-based dependency specifiers to the exact versions resolved by the lockfile

Usage: npd [OPTIONS]

Options:
  -q, --quiet              Silent mode — no output
  -v, --verbose            Verbose output
  -d, --debug              Debug mode — detailed logging
  -u, --update             Update package.json with pinned versions
      --json               Output results as JSON
      --sort               Sort package.json keys (sort-package-json conventions); writes the file even without --update or pending pins
      --enable-save-exact  Create or update .npmrc with save-exact=true
      --pin-catalog        Resolve and report pnpm catalog entries from `pnpm-workspace.yaml`. On `-u`, rewrites the catalog entries in place. Requires a pnpm project
  -h, --help               Print help
  -V, --version            Print version

Workspace mode

When run from the root of an npm, pnpm, or yarn workspace, npd auto-detects the workspace and pins each member's package.json against the shared root lockfile. Output is grouped per member. --pin-catalog continues to operate on the root pnpm-workspace.yaml.


Debug

npd -d

The -d/--debug flag enables detailed logging to stderr. No environment variable is required.

  ▸ Detecting lockfile......
  ✓ Detected package-lock.json
  ▸ Reading package.json......
  ✓ Read package.json
  ▸ Parsing lockfile......
  ✓ Parsed lockfile
  ▸ Computing dependency pins......
    Pin ~18.2.0 → 18.2.0 bucket="dependencies" package=bar
    Pin ^4.17.21 → 4.17.21 bucket="dependencies" package=foo
    Pin ^1.0.0 → 1.6.0 bucket="devDependencies" package=baz
  ✓ Computed dependency pins
    bar  ~18.2.0   →  18.2.0
    foo  ^4.17.21  →  4.17.21
    baz  ^1.0.0    →  1.6.0

  Run npd -d -u to upgrade package.json.