</>PackageGraphPackageGraph

invariant

npmv2.2.4

invariant

Not recommended for new projects

No — invariant should not be adopted for new projects. Last published 3102 days ago.

  • ?Adoption: grade ?, Not reported by this registry.

    No download data reported for this package yet.

  • FMaintenance: grade F, Failing.

    Last published 3102 days ago.

  • AWeight: grade A, Excellent.

    Pulls in 2 transitive packages, about 13 KB installed (at least — some of the tree is still being crawled).

  • ASupply chain: grade A, Excellent.

    No install scripts, 2 maintainers, and a contained dependency surface.

  • ALicense: grade A, Excellent.

    MIT — permissive, with no copyleft found in the dependency tree.

Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.

Install cost

What you actually take on by adding invariant to a project.

1
Direct dependencies

Runtime packages this one declares itself.

2
Total installed

Distinct packages in the full runtime tree, deduplicated the way a package manager would.

13 KB
Install size

Unpacked size of this package plus its entire runtime tree.

2
Tree depth

Longest resolved dependency chain below this package.

Part of this dependency tree has not been crawled yet, so these figures are a lower bound rather than a final total.

Licenses in the dependency tree

MIT

Every license you inherit by installing invariant, not just its own. Check this before a legal review, not after.

Compatibility

Node.js
No constraint declared
Module format
CommonJS only
TypeScript
No bundled types
Install scripts
None

Quick start

A usage example from the invariant README.

var invariant = require('invariant');

invariant(someTruthyVal, 'This will not throw');
// No errors

invariant(someFalseyVal, 'This will throw an error with this message');
// Error: Invariant Violation: This will throw an error with this message

invariant vs the alternatives

Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.

PackageWeekly downloadsDependentsLicenseLast release
invariantthis page016MIT8 years ago
p-locate216.9M1MIT17 hours ago
is-glob137.4M3MIT16 hours ago
is-plain-obj112.9M1MIT17 hours ago
vitest92.7M129MIT8 hours ago
assertion-error89.6M2MIT17 hours ago

Dependencies

Declared by invariant v2.2.4. Runtime dependencies are installed with the package; dev dependencies are not.

Dev (3)

browserify ^11.0.1flow-bin ^0.67.1tap ^1.4.0

Used by

Popular packages that depend on invariant.

babel-plugin-react-compilernpm

Babel plugin for React Compiler.

0/wk2 dependentsMITTS
react-nativenpm

A framework for building native apps using React

0/wk30 dependentsMIT
expo-modules-corenpm

The core of Expo Modules architecture

0/wk1 dependentsMITTS
react-native-webviewnpm

React Native WebView component for iOS, Android, macOS, and Windows

0/wk1 dependentsMITTS
@react-native/community-cli-pluginnpm

Core CLI commands for React Native

0/wk1 dependentsMIT
metro-source-mapnpm

🚇 Source map generator for Metro.

0/wk5 dependentsMITTS
@react-native/virtualized-listsnpm

Virtualized lists for React Native.

0/wk1 dependentsMITTS
@react-native/codegennpm

Code generation tools for React Native

0/wk2 dependentsMIT
@react-native/dev-middlewarenpm

Dev server middleware for React Native

0/wk2 dependentsMIT
@expo/metro-file-mapnpm

A metro-file-map fork for Expo used with the Metro bundler

0/wk1 dependentsMITTS
expo-routernpm

Expo Router is a file-based router for React Native and web applications.

0/wk2 dependentsMITTS
metro-file-mapnpm

[Experimental] - 🚇 File crawling, watching and mapping for Metro

0/wk2 dependentsMITTS
metro-symbolicatenpm

🚇 A tool to find the source location from JS bundles and stack traces.

0/wk3 dependentsMITTS
metronpm

🚇 The JavaScript bundler for React Native.

0/wk6 dependentsMITTS
react-native-gesture-handlernpm

Declarative API exposing native platform touch and gesture system to React Native

0/wk3 dependentsMITTS
expo-linkingnpm

Create and open deep links universally

0/wk1 dependentsMITTS

Relationship graph

Dependencies (left) and dependents (right) of invariant.

Frequently installed together

Release history

No releases in the last two years, typically about 102 days apart.

Recent versions of invariant
VersionPublishedSizeLicense
2.2.4latest8 years ago7.5 KBMIT
2.2.38 years ago6.9 KBMIT
2.2.29 years agoBSD-3-Clause
2.2.110 years agoBSD-3-Clause
2.2.010 years agoBSD-3-Clause
2.1.310 years agoBSD-3-Clause
2.1.211 years agoBSD-3-Clause
2.1.111 years agoBSD-4-Clause
2.1.011 years agoBSD
2.0.011 years agoMIT
1.0.212 years agoMIT
1.0.112 years agoMIT
1.0.012 years agoMIT

Overview

invariant is an npm package that invariant. It has 16 known dependents in the graph. The latest version is 2.2.4, released under the MIT license.

Who should use it

Teams working in the npm ecosystem who need invariant and value a focused solution.

When not to use it

Consider an alternative if you need to have first-class TypeScript types out of the box, or if a more actively-maintained option better fits your npm stack.

Pros

  • Clear open-source license (MIT).

Cons

  • No bundled TypeScript types (may require a separate @types package).

Auto-generated from collected registry metadata. No external claims are inferred.

Maintainers

Keywords

Frequently asked questions

Should I use invariant?

No — invariant should not be adopted for new projects. Last published 3102 days ago.

How do I install invariant?

Run `npm install invariant` to add invariant to your npm project.

How many dependencies does invariant have?

invariant declares 4 direct dependencies and pulls in 2 packages in total once its runtime tree is resolved totalling about 13 KB on disk.

What license is invariant released under?

invariant is distributed under the MIT license.

How popular is invariant?

npm does not publish download counts. Within PackageGraph's crawl, 16 known packages depend on invariant.

Is invariant still maintained?

The most recent release of invariant (v2.2.4) was published 8 years ago.

Does invariant run install scripts?

No. invariant does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.