333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# import-fresh [![Build Status](https://travis-ci.org/sindresorhus/import-fresh.svg?branch=master)](https://travis-ci.org/sindresorhus/import-fresh)
 
> Import a module while bypassing the [cache](https://nodejs.org/api/modules.html#modules_caching)
 
Useful for testing purposes when you need to freshly import a module.
 
 
## Install
 
```
$ npm install import-fresh
```
 
 
## Usage
 
```js
// foo.js
let i = 0;
module.exports = () => ++i;
```
 
```js
const importFresh = require('import-fresh');
 
require('./foo')();
//=> 1
 
require('./foo')();
//=> 2
 
importFresh('./foo')();
//=> 1
 
importFresh('./foo')();
//=> 1
```
 
 
## Related
 
- [clear-module](https://github.com/sindresorhus/clear-module) - Clear a module from the import cache
- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory
- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily
 
 
---
 
<div align="center">
    <b>
        <a href="https://tidelift.com/subscription/pkg/npm-require-uncached?utm_source=npm-require-uncached&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
    </b>
    <br>
    <sub>
        Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
    </sub>
</div>