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 🙏

© 2024 – Pkg Stats / Ryan Hefner

satisfaction

v3.2.0

Published

Verifies that a node_modules dir satisfies a package.json file

Downloads

43

Readme

Satisfaction

Build Status NPM Version License Dependency Status devDependency Status

Verifies that a package.json file is satisfied by its node_modules dir.

Satisfaction uses the Semver package (which is used by NPM) to verify that the versions installed in your node_modules satisfy the requirement defined in your package.json, and can also verify that all of your dependencies are required with specific versions, (no ~, ^, >=, etc).


Installation

$ npm i satisfaction

or globally:

$ npm i -g satisfaction

Usage

As a dependency

const satisfaction = require('satisfaction')

const statusErrors = satisfaction.checkStatus()
if (statusErrors.length) {
  throw new Error(`node_modules does not satisfy package.json:\n${statusErrors.join('\n')}`)
}

const exactErrors = satisfaction.checkExact()
if (exactErrors.length) {
  throw new Error(`Dependencies are not exact versions:\n${exactErrors.join('\n')}`)
}

Likely use in Grunt:

grunt.registerTask('verify-npm', () => {
  const satisfaction = require('satisfaction')

  const statusErrors = satisfaction.checkStatus()
  if (statusErrors.length) {
    grunt.fail.warn(`node_modules does not satisfy package.json:\n${statusErrors.join('\n')}`)
  }

  const exactErrors = satisfaction.checkExact()
  if (exactErrors.length) {
    grunt.fail.warn(`Dependencies are not exact versions:\n${exactErrors.join('\n')}`)
  }
})

Both statusErrors and exactErrors accept an options object:

console.log(require('satisfaction').statusErrors({
  dir: someDir // containing folder of package.json and node_modules, defaults to process.cwd()
}).join('\n'))

As a global

The satisfaction-status and satisfaction-exact global binaries will throw errors listing which violations were found.

Running satisfaction-status || npm i will be prevent npm i from running when everything is already installed with compliant versions.

Example errors for running satisfaction-status:

Error: node_modules does not satisfy package.json:
package eslint installed with 3.6.1 but required 3.6.2
package ava is not installed

Example errors for running satisfaction-exact:

Error: Dependencies are not exact versions:
package lodash is required with a non-exact version ^4.16.2

Notes / Caveats

  • When using git urls in dependencies, (like "byRepo": "git+ssh://[email protected]:repo.git#3.5.3" or like "byRepo": "githubuser/githubrepo#3.5.3"), it must be done with a tag (3.5.3 or v3.5.3) that corresponds to the version of said package (3.5.3), or it will be considered an error.
  • Checks the "dependencies" and "devDependencies" fields of package.json.

Feedback