Installations
npm install clear-module
Developer Guide
Typescript
Yes
Module System
N/A
Min. Node Version
>=8
Node Version
17.0.1
NPM Version
8.1.0
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (97.98%)
TypeScript (2.02%)
Developer
sindresorhus
Download Statistics
Total Downloads
76,311,662
Last Day
135,294
Last Week
662,215
Last Month
2,913,173
Last Year
33,885,588
GitHub Statistics
181 Stars
29 Commits
25 Forks
9 Watching
1 Branches
7 Contributors
Bundle Size
2.01 kB
Minified
826.00 B
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
4.1.2
Package Id
clear-module@4.1.2
Size
2.37 kB
NPM Version
8.1.0
Node Version
17.0.1
Publised On
03 Nov 2021
Total Downloads
Cumulative downloads
Total Downloads
76,311,662
Last day
-9.1%
135,294
Compared to previous day
Last week
-13.7%
662,215
Compared to previous week
Last month
-5.3%
2,913,173
Compared to previous month
Last year
73.9%
33,885,588
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
clear-module
Clear a module from the cache
Useful for testing purposes when you need to freshly import a module.
Install
$ npm install clear-module
Usage
1// foo.js 2let i = 0; 3module.exports = () => ++i;
1const clearModule = require('clear-module'); 2 3require('./foo')(); 4//=> 1 5 6require('./foo')(); 7//=> 2 8 9clearModule('./foo'); 10 11require('./foo')(); 12//=> 1
API
clearModule(moduleId)
moduleId
Type: string
What you would use with require()
.
clearModule.all()
Clear all modules from the cache.
clearModule.match(regex)
Clear all matching modules from the cache.
regex
Type: RegExp
Regex to match against the module IDs.
clearModule.single(moduleId)
Clear a single module from the cache non-recursively. No parent or children modules will be affected.
This is mostly only useful if you use singletons, where you would want to clear a specific module without causing any side effects.
moduleId
Type: string
What you would use with require()
.
Related
- import-fresh - Import a module while bypassing the cache
- import-from - Import a module from a given path
- import-cwd - Import a module from the current working directory
- import-lazy - Import a module lazily
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 7/29 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/clear-module/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/clear-module/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:23
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More