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

get-pkg-prop

v0.3.1

Published

Pass a key name & get the corresponding value from the intended package.json

Readme

get-pkg-prop

Pass a key name & get the corresponding value from the intended package.json

travis CI build status

Getting Started

Install

npm install get-pkg-prop -S

Add to source

import { getPkgProp } from "get-pkg-prop";

Use

import { getPkgProp } from 'get-pkg-prop'

const pkgMock = { version: "1.0.0", custom: { foo: "bar", baz: "bax" }   }

(async () => {
  await getPkgProp("name");
  // --> "get-pkg-prop"
  await getPkgProp("version", "path/to/child/module");
  // --> "x.y.z"
  await getPkgProp("custom", pkgMock)
  // --> { foo: "bar", baz: "bax" }
  await getPkgProp("fakeprop");
  // --> false
})

API

  • szProperty is the name of the property.

How

  • This uses pkg-up to find the closest package.json.

Why

  • Useful for confirmations when toggling between local linked deps and remote installed deps. I wanted to enable modules to self-report relevant meta info (like their version)
import { getPkgProp } from 'get-pkg-prop'

(async () => {
  await getPkgProp("name")
  // --> "get-pkg-prop"
  await getPkgProp("version")
  // --> "0.2.6"
  await getPkgProp()
  // --> null; must provide property to check
  await getPkgProp("xyz")
  // --> false; property must exist in package.json
  await getPkgProp("repository")
  // --> { "type": "git", "url": "https://github.com/servexyz/get-pkg-prop" }
  */
})
  • szProperty is the name of the property.
  • oPackageJSON is the JSON object which contains your package

Why

  • I added this for mock testing inline package objects.
import { getPkgProp } from 'get-pkg-prop'

const pkgMock = {
  "name": "my-pkg",
  "version": "1.0.0",
  "repository": {
      "type": "git",
      "url": "https://github.com/namespace/my-repo-pkg"
  }
}

(async () => {
  await getPkgProp("name", pkgMock)
  // --> "my-pkg"
  await getPkgProp("name")
  // --> "get-pkg-prop"; defaults to current pkg when unspecified
  await getPkgProp("version", pkgMock)
  // --> "0.2.6"
  await getPkgProp(, pkgMock)
  // --> null; must provide property to check
  await getPkgProp("xyz")
  // --> false; property must exist in package.json
  await getPkgProp("repository", pkgMock)
  // -->  { "type": "git", "url": "https://github.com/namespace/my-repo-pkg" }
  await getPkgProp("repository")
  // pkgMock wasn't specified, it returns value of cwd package:
  // -->  { "type": "git", "url": "https://github.com/servexyz/get-pkg-prop" }
})
  • szProperty is the name of the property.
  • szPathToPackageJSON is the path to either your package.json file or the directory which contains the package.json file.

Why

  • Specifying the path allows you to access the package of sub-modules or installed dependencies.

Note

  • "path/to/child/module" and "path/to/child/module/package.json" are processed equally
import { getPkgProp } from 'get-pkg-prop'

(async () => {
  await getPkgProp("name")
  // --> "get-pkg-prop"; defaults to current pkg when unspecifeid
  await getPkgProp("name", "path/to/child/module")
  // --> "child-module-name"
  await getPkgProp("version", "path/to/child/module")
  // --> "x.y.z"
  await getPkgProp(,"path/to/child/module")
  // --> null; must provide property to check
  await getPkgProp("xyz", "path/to/child/module")
  // --> false; property must exist in package.json
  await getPkgProp("repository", "path/to/child/module")
  // --> { "type": "git", "url": "https://github.com/namespace/child-module-name" }
})

FAQ