invariant
npmv2.2.4invariant
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.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
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
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 messageinvariant vs the alternatives
Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.
| Package | Weekly downloads | Dependents | License | Last release |
|---|---|---|---|---|
| invariantthis page | 0 | 16 | MIT | 8 years ago |
| p-locate | 216.9M | 1 | MIT | 17 hours ago |
| is-glob | 137.4M | 3 | MIT | 16 hours ago |
| is-plain-obj | 112.9M | 1 | MIT | 17 hours ago |
| vitest | 92.7M | 129 | MIT | 8 hours ago |
| assertion-error | 89.6M | 2 | MIT | 17 hours ago |
Dependencies
Declared by invariant v2.2.4. Runtime dependencies are installed with the package; dev dependencies are not.
Runtime (1)
Dev (3)
Used by
Popular packages that depend on invariant.
Babel plugin for React Compiler.
A framework for building native apps using React
The core of Expo Modules architecture
React Native WebView component for iOS, Android, macOS, and Windows
Core CLI commands for React Native
🚇 Source map generator for Metro.
Virtualized lists for React Native.
Code generation tools for React Native
Dev server middleware for React Native
A metro-file-map fork for Expo used with the Metro bundler
Expo Router is a file-based router for React Native and web applications.
[Experimental] - 🚇 File crawling, watching and mapping for Metro
🚇 A tool to find the source location from JS bundles and stack traces.
🚇 The JavaScript bundler for React Native.
Declarative API exposing native platform touch and gesture system to React Native
Create and open deep links universally
Relationship graph
Dependencies (left) and dependents (right) of invariant.
Frequently installed together
React is a JavaScript library for building user interfaces.
A framework for building native apps using React
TypeScript definitions for react
Simple and complete React Native testing utilities that encourage good testing practices.
Native navigation primitives for your React Native app.
More powerful alternative to Animated library for React Native.
Lightweight debugging utility for Node.js and the browser
React Native for Web
Error overlay for universal Expo apps.
The Expo SDK
React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.
Tools for making advanced Metro bundler features work
Release history
No releases in the last two years, typically about 102 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 2.2.4latest | 8 years ago | 7.5 KB | MIT |
| 2.2.3 | 8 years ago | 6.9 KB | MIT |
| 2.2.2 | 9 years ago | — | BSD-3-Clause |
| 2.2.1 | 10 years ago | — | BSD-3-Clause |
| 2.2.0 | 10 years ago | — | BSD-3-Clause |
| 2.1.3 | 10 years ago | — | BSD-3-Clause |
| 2.1.2 | 11 years ago | — | BSD-3-Clause |
| 2.1.1 | 11 years ago | — | BSD-4-Clause |
| 2.1.0 | 11 years ago | — | BSD |
| 2.0.0 | 11 years ago | — | MIT |
| 1.0.2 | 12 years ago | — | MIT |
| 1.0.1 | 12 years ago | — | MIT |
| 1.0.0 | 12 years ago | — | MIT |
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.
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.