Big update!Introducing GitHub Bot Commands. Learn more
Log inBook a demo


Package Overview
File Explorer

Advanced tools


A mirror of Facebook's Warning


Version published
Weekly downloads
decreased by-8.74%

Weekly downloads



4.0.3 (2019-02-09)

Bug Fixes

  • incorrect formatting of message with arguments (b188176)

<a name="4.0.2"></a>



Warning npm version

Greenkeeper badge A mirror of Facebook's Warning


npm install warning // some script var warning = require('warning'); var ShouldBeTrue = false; warning( ShouldBeTrue, 'This thing should be true but you set to false. No soup for you!' ); // 'This thing should be true but you set to false. No soup for you!'

Similar to Facebook's (FB) invariant but only logs a warning if the condition is not met. This can be used to log issues in development environments in critical paths. Removing the logging code for production environments will keep the same logic and follow the same code paths.

FAQ (READ before opening an issue)

Why do you use console.error instead of console.warn ?

This is a mirror of Facebook's (FB) warning module used within React's source code (and other FB software). As such this module will mirror their code as much as possible.

The descision to use error over warn was made a long time ago by the FB team and isn't going to change anytime soon.

The source can be found here: The reasoning can be found here and elsewhere:

Can I add X feature?

This is a mirror of Facebook's (FB) warning and as such the source and signature will mirror that module.

If you believe a feature is missing than please open a feature request there. If it is approved and merged in that this module will be updated to reflect that change, otherwise this module will not change.

Use in Production

It is recommended to add babel-plugin-dev-expression with this module to remove warning messages in production.

Don't Forget To Be Awesome



What is warning?

A mirror of Facebook's Warning

Is warning popular?

The npm package warning receives a total of 8,643,701 weekly downloads. As such, warning popularity was classified as popular.

Is warning well maintained?

We found that warning demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 09 Feb 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket


Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc