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

pnpm-version-util

v1.0.0

Published

Simple CLI utility to read package version from package.json - a pnpm-friendly alternative to 'npm version'

Readme

pnpm-version-util

npm version License: MIT

A simple CLI utility to read package version from package.json - a pnpm-friendly alternative to npm version.

🎯 Problem

Running pnpm version doesn't work because pnpm doesn't have a native version command. When it falls back to npm, it often fails due to package manager constraints or workspace configurations.

✨ Solution

This package provides a simple CLI that reads the version from package.json in the current directory. No configuration needed, just works!

📦 Installation

Global Installation (Recommended)

npm install -g pnpm-version-util
# or
pnpm add -g pnpm-version-util

Local Installation (For Monorepos)

pnpm add -D pnpm-version-util

🚀 Usage

Method 1: Direct Command

After global installation:

pnpm-version
# Output: 1.0.0

Method 2: Using pnpm exec (Local installation)

pnpm exec pnpm-version
# Output: 1.0.0

Method 3: Add to package.json scripts

{
  "scripts": {
    "version": "pnpm-version"
  }
}

Then run:

pnpm run version
# Output: 1.0.0

Optional: Create an alias

For even shorter commands, add to your ~/.zshrc or ~/.bashrc:

alias pv='pnpm-version'

Then simply run:

pv
# Output: 1.0.0

📖 Output

Always outputs just the version number with no extra noise:

1.0.0

Clean output makes it perfect for:

  • Quick version checks during development
  • Scripting and automation
  • CI/CD pipelines
  • Git tags and release workflows

Example: Use in scripts

# Create git tag from package version
git tag "v$(pnpm-version)"

# Use in release script
VERSION=$(pnpm-version)
echo "Releasing version $VERSION"

🔌 Programmatic API

You can also use this package programmatically in your Node.js code:

import { getVersion } from 'pnpm-version-util';

// Get version from current directory
const version = getVersion();
console.log(version); // "1.0.0"

// Get version from specific directory
const version = getVersion({ cwd: '/path/to/package' });
console.log(version); // "2.3.4"

API Types

interface GetVersionOptions {
  /** Path to the directory containing package.json. Defaults to current working directory. */
  cwd?: string;
}

function getVersion(options?: GetVersionOptions): string

💡 Use Cases

  • Monorepo Management: Quickly check versions of different packages
  • Release Automation: Get version for tagging and changelog generation
  • CI/CD Pipelines: Integrate into build and deployment scripts
  • Development: Quick version checks without opening files

✅ Benefits

Zero Configuration - Works out of the box
Clean Output - Just the version number, nothing else
Fast - Synchronous file read, instant results
Reliable - Comprehensive test coverage
Flexible - CLI + programmatic API
TypeScript - Full type definitions included

🛠️ Requirements

  • Node.js >= 18
  • pnpm (optional, works with npm/yarn too)

🧪 Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Build
pnpm run build

# Run locally
./build/cli.js

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

MIT © Amitai Salmon

🐛 Issues

Found a bug or have a suggestion? Please open an issue.

⭐ Show your support

Give a ⭐️ if this project helped you!