Registry / devops / webpack-clear-require-cache-plugin

webpack-clear-require-cache-plugin

JSON →
library0.0.5jsnpmunverified

A webpack plugin that clears modules from Node.js require.cache after the webpack compilation's afterEmit hook. Version 0.0.5, stable but limited maintenance. It accepts an array of regex patterns; during compilation, each cached module path is tested and removed if it matches. Primarily useful for development with npm-linked packages that need cache invalidation on rebuild. Works with webpack and Next.js servers. Simpler than using Nodemon or chokidar-based solutions, but limited to webpack-based projects.

npm install webpack-clear-require-cache-plugin
INSTALL
IMPORT
SIG · WEBPACK-CLEAR-REQU
W
webpack-clear-require-cache-plugin
devopsjavascriptv0.0.5
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

clearRequireCachePlugin
✓ const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin');
✗ import clearRequireCachePlugin from 'webpack-clear-require-cache-plugin';
Package uses CommonJS; no default ESM export. Use require for compatibility.
plugin instance
✓ clearRequireCachePlugin([/my-module/])
✗ new clearRequireCachePlugin({ patterns: [/my-module/] })
Plugin is a function that returns a webpack plugin object; do not use 'new' or pass an options object.

Shows basic usage: import the plugin function and pass an array of regex patterns to clear require cache for linked modules.

const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin'); module.exports = { // ... other webpack config plugins: [ clearRequireCachePlugin([ /my-module/, ]), ], };
Debug
Known issues
gotchaPlugin only works in Node.js environments (e.g., webpack dev server, Next.js server-side builds). Does not affect client-side webpack bundles.
fix
Ensure you only use this plugin in server-side webpack configurations.
affects: >=0.0.0
deprecatedPackage has not been updated since 2018; may not be compatible with webpack 5+ or Next.js built-in features.
fix
Consider using native webpack module federation or dedicated cache-clearing plugins for modern webpack.
affects: >=0.0.0
gotchaRegex patterns are tested against full module paths, not just module names. Include path separators or anchors if needed.
fix
Use patterns like /node_modules\/my-module/ to avoid clearing unrelated modules.
affects: >=0.0.0
gotchaPlugins that rely on require.cache may not work with webpack 5's persistent caching (filesystem cache).
fix
Disable filesystem cache when using this plugin: config.cache = false.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: clearRequireCachePlugin is not a constructor
Using 'new' on the module export, which is a function, not a class.
fix
Use clearRequireCachePlugin([...]) without 'new'.
Cannot find module 'webpack-clear-require-cache-plugin'
Missing npm install or incorrect import path.
fix
Run npm install --save-dev webpack-clear-require-cache-plugin and require with correct casing.
Module not found: Error: Can't resolve 'webpack-clear-require-cache-plugin'
Using ES import syntax for a CommonJS-only package.
fix
Change to const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin');
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
webpack-clear-require-cache-plugin — npm install webpack-clear-require-cache-plugin · libregistry