# @joshrtay/decache

> decache (Delete Cache) lets you delete modules from node.js require() cache; useful for dev servers

Latest version **4.0.1** (published 2016-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @joshrtay/decache
pnpm add @joshrtay/decache
yarn add @joshrtay/decache
bun add @joshrtay/decache
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2016-07-25 |
| First published | 2016-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | @besarthoxhaj, @jupiter & @nelsonic |
| Maintainers | joshrtay |
| Keywords | delete, node.js, require, cache, uncache, un-require |

## Links

- npm: https://www.npmjs.com/package/@joshrtay/decache
- Repository: https://github.com/joshrtay/decache
- Homepage: https://github.com/joshrtay/decache#readme
- Issues: https://github.com/joshrtay/decache/issues
- npm.io page: https://npm.io/package/@joshrtay/decache

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2016-07-25

## README

# decache

[![Build Status](https://travis-ci.org/dwyl/decache.svg)](https://travis-ci.org/dwyl/decache)
[![codecov.io](https://codecov.io/github/dwyl/decache/coverage.svg?branch=master)](https://codecov.io/github/dwyl/decache?branch=master)
[![Code Climate](https://codeclimate.com/github/dwyl/decache/badges/gpa.svg)](https://codeclimate.com/github/dwyl/decache)
[![Dependency Status](https://david-dm.org/dwyl/decache.svg)](https://david-dm.org/dwyl/decache)
[![devDependency Status](https://david-dm.org/dwyl/decache/dev-status.svg)](https://david-dm.org/dwyl/decache#info=devDependencies)

In node.js when you `require()` a module, node stores a cached version of the
module, so that all subsequent calls to `require()` do not have to reload
the module from the filesystem.

`decache` ( _**De**lete **Cache**_ ) lets you delete modules from node.js `require()` cache
this is useful when _**testing**_ your modules/projects.

## Why?

When testing our modules we often need to re-require the module being tested.
This makes it easy.

## What?

An easy way to delete a cached module.

## How? (_usage_)

### install

Install the module from npm:

```sh
npm install decache --save-dev
```

### Use it in your code:

```js
// require the decache module:
var decache = require('decache');

// require a module that you wrote"
var mymod = require('./mymodule.js');

// use your module the way you need to:
console.log(mymod.count()); // 0   (the initial state for our counter is zero)
console.log(mymod.incrementRunCount()); // 1

// delete the cached module:
decache('./mymodule.js');

//
mymod = require('./mymodule.js'); // fresh start
console.log(mymod.count()); // 0   (back to initial state ... zero)
```

Modules other than `.js`, like for example, `.jsx`, are supported as well.

If you have any questions or need more examples, please create a GitHub issue:
https://github.com/nelsonic/decache/issues

***Thanks***!

---
_Source: https://npm.io/package/@joshrtay/decache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
