Registry / devops / fresh-require

fresh-require

JSON →
library1.0.3jsnpmunverified

Bypass the Node.js require cache to reload modules fresh, avoiding stale cached versions. v1.0.3 is the latest stable release; the package is in maintenance mode with no active development. It supports both plain Node and Browserify (via a transform). Unlike other cache-busting utilities, it requires explicitly passing your local require function, making it safe for bundled use. Works by deleting the cached module entry before re-requiring. Current NPM downloads: ~2k/month.

npm install fresh-require
INSTALL
IMPORT
SIG · FRESH-REQUIRE
F
fresh-require
devopsjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

fresh
const fresh = require('fresh-require')
import fresh from 'fresh-require'
Package is CommonJS only; no ES module export available.
fresh (default)
var fresh = require('fresh-require')
const fresh = require('fresh-require').default
No default export; require returns the function directly.
fresh (with require)
var async2 = fresh('async', require)
var async2 = fresh('async', require.resolve)
Second argument must be the caller's local require function, not require.resolve or a different require.

Demonstrates requiring a fresh copy of 'fs' module, bypassing the cache.

var fresh = require('fresh-require'); // Reload a module fresh, bypassing cache var fs = require('fs'); var fsFresh = fresh('fs', require); console.log(fs === fsFresh); // false // For browserify, add transform: browserify -t fresh-require/transform
Debug
Known issues
gotchaThe second argument must be the caller's local require function. Passing a different require (e.g., from another module) will cause unexpected behavior.
fix
Always pass your module's own require: fresh('mod', require).
affects: >=1.0.0
gotchaIn browserify, you must include the transform fresh-require/transform using -t flag, otherwise fresh-require will not work correctly.
fix
Add '-t fresh-require/transform' to your browserify command.
affects: >=1.0.0
deprecatedPackage is in maintenance mode with no recent updates. May not support newer Node.js versions or ESM modules.
fix
Consider alternatives like 'clear-module' or 'import-fresh' for ESM support.
affects: >=1.0.0
gotchaDoes not work with native ES modules (import/export) because it relies on require's synchronous module loading.
fix
Use 'import-fresh' for ESM modules.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'fresh-require/transform'
Missing transform dependency or browserify not run with -t flag.
fix
Install fresh-require and run browserify with -t: 'browserify -t fresh-require/transform yourfile.js > bundle.js'
TypeError: require is not a function
Second argument to fresh() is not the local require function.
fix
Ensure you pass your module's require: fresh('mod', require) (not require() or require.resolve)
Error: Cannot find module 'async'
Module name passed to fresh() is incorrect or not installed.
fix
Verify the module name string matches exactly; e.g., if the package is 'async', use fresh('async', require)
Warning: fresh-require/transform should be used as a browserify transform
Transform not applied; package gracefully degrades but may not work in browserified bundle.
fix
Add '-t fresh-require/transform' to browserify command.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fresh-require — npm install fresh-require · libregistry