{"id":20724,"library":"webpack-clear-require-cache-plugin","title":"Webpack Clear Require Cache Plugin","description":"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.","status":"maintenance","version":"0.0.5","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","webpack","plugin","clear","require","cache"],"install":[{"cmd":"npm install webpack-clear-require-cache-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-clear-require-cache-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-clear-require-cache-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package uses CommonJS; no default ESM export. Use require for compatibility.","wrong":"import clearRequireCachePlugin from 'webpack-clear-require-cache-plugin';","symbol":"clearRequireCachePlugin","correct":"const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin');"},{"note":"Plugin is a function that returns a webpack plugin object; do not use 'new' or pass an options object.","wrong":"new clearRequireCachePlugin({ patterns: [/my-module/] })","symbol":"plugin instance","correct":"clearRequireCachePlugin([/my-module/])"}],"quickstart":{"code":"const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin');\n\nmodule.exports = {\n  // ... other webpack config\n  plugins: [\n    clearRequireCachePlugin([\n      /my-module/,\n    ]),\n  ],\n};","lang":"javascript","description":"Shows basic usage: import the plugin function and pass an array of regex patterns to clear require cache for linked modules."},"warnings":[{"fix":"Ensure you only use this plugin in server-side webpack configurations.","message":"Plugin only works in Node.js environments (e.g., webpack dev server, Next.js server-side builds). Does not affect client-side webpack bundles.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using native webpack module federation or dedicated cache-clearing plugins for modern webpack.","message":"Package has not been updated since 2018; may not be compatible with webpack 5+ or Next.js built-in features.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use patterns like /node_modules\\/my-module/ to avoid clearing unrelated modules.","message":"Regex patterns are tested against full module paths, not just module names. Include path separators or anchors if needed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Disable filesystem cache when using this plugin: config.cache = false.","message":"Plugins that rely on require.cache may not work with webpack 5's persistent caching (filesystem cache).","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.0.5':23 'accept':29 'afteremit':20 'array':31 'base':76,83 'cach':4,38,59,90 'chokidar':75 'chokidar-bas':74 'clear':2,10,88 'compil':18,36 'develop':51 'hook':21 'invalid':60 'javascript':85 'limit':26,79 'link':55 'mainten':27 'match':47 'modul':11,39 'need':58 'next.js':67 'node.js':13 'nodemon':72 'npm':54 'npm-link':53 'packag':56 'path':40 'pattern':34 'plugin':5,8,87 'primarili':48 'project':84 'rebuild':62 'regex':33 'remov':44 'requir':3,89 'require.cache':14 'server':68 'simpler':69 'solut':77 'stabl':24 'test':42 'use':49,71 'version':22 'webpack':1,7,17,65,82,86 'webpack-bas':81 'work':63","created_at":"2026-04-25T11:24:38.427866+00:00","updated_at":"2026-04-25T11:24:38.427866+00:00","problems":[{"fix":"Use clearRequireCachePlugin([...]) without 'new'.","cause":"Using 'new' on the module export, which is a function, not a class.","error":"TypeError: clearRequireCachePlugin is not a constructor"},{"fix":"Run npm install --save-dev webpack-clear-require-cache-plugin and require with correct casing.","cause":"Missing npm install or incorrect import path.","error":"Cannot find module 'webpack-clear-require-cache-plugin'"},{"fix":"Change to const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin');","cause":"Using ES import syntax for a CommonJS-only package.","error":"Module not found: Error: Can't resolve 'webpack-clear-require-cache-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/webpack-clear-require-cache-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}