Registry / devops / import-without-cache

import-without-cache

JSON →
library0.4.0jsnpmunverified

Import ES modules without cache. Current stable version is 0.4.0, released in 2025. This library intercepts Node.js module loading via hooks to bypass the ESM cache, ensuring fresh imports for every call. It also clears CommonJS cache with clearRequireCache(). Compared to alternatives like clear-module or decache, it supports ES modules natively and handles dependency chains without caching. Requires Node.js ^22.18.0 or >=24.0.0. Not supported on Deno; Yarn PnP requires Node >=24.

npm install import-without-cache
INSTALL
IMPORT
SIG · IMPORT-WITHOUT-CAC
I
import-without-cache
devopsjavascriptv0.4.0
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.

init
import { init } from 'import-without-cache'
import init from 'import-without-cache'
init is a named export, not default.
clearRequireCache
import { clearRequireCache } from 'import-without-cache'
const clearRequireCache = require('import-without-cache').clearRequireCache
Package is ESM-only; require() is not supported.
isSupported
import { isSupported } from 'import-without-cache'
Check isSupported at runtime before using init to avoid errors on unsupported platforms.

Demonstrates importing ES modules without cache using both import attributes and no-cache:// protocol, plus clearing CommonJS cache.

import { init, clearRequireCache, isSupported } from 'import-without-cache' if (!isSupported) { throw new Error('import-without-cache is not supported in this environment.') } const deregister = init({ skipNodeModules: false, // Optional: set true to skip node_modules }) // Option 1: use import attributes const mod1 = await import('module-a', { with: { cache: 'no' } }) // Option 2: use no-cache:// protocol const mod2 = await import('no-cache://module-a') console.log('Same instance (should be false):', mod1 === mod2) clearRequireCache() // Optional: clears CommonJS require cache deregister() // Clean up hooks when done
Debug
Known issues
breakingRequires Node.js ^22.18.0 or >=24.0.0; will throw on older versions.
fix
Upgrade Node.js to version 22.18.0 or later, or 24.0.0 or later.
affects: <22.18.0
gotchaYarn PnP is not supported on Node.js versions earlier than v24.
fix
Use Node.js >=24.0.0 with Yarn PnP, or use a different package manager (npm/pnpm).
affects: >=0.0.0 <24.0.0
gotchaDeno is not supported at all.
fix
Do not use this package with Deno; consider alternative cache-busting methods.
affects: >=0.0.0
gotchaOnly ESM modules are supported by default. CommonJS cache must be cleared separately with clearRequireCache().
fix
Call clearRequireCache() after init to clear CommonJS require cache if needed.
affects: >=0.0.0
gotchaIn Bun, init() is unnecessary because ESM imports already behave like CommonJS requires (no caching). clearRequireCache works if you need to clear CJS cache.
fix
On Bun, skip calling init() and only use clearRequireCache() if needed.
affects: >=0.0.0
deprecatedrequire(esm) is supported starting in Node.js v24.13.1; earlier versions will throw.
fix
Use dynamic import() instead of require() for ESM modules, or upgrade to Node.js >=24.13.1.
affects: <24.13.1
Errors
Common errors & fixes
TypeError: The 'no-cache://' protocol hook is not installed.
Forgot to call init() before using the no-cache:// protocol.
fix
Call init() at the start of your application before any no-cache:// import.
ERR_UNSUPPORTED_ESM_URL_SCHEME
Used import-without-cache with a non-ESM module or incompatible environment.
fix
Ensure you are running Node.js ^22.18.0 or >=24.0.0, and that the imported module is ESM.
SyntaxError: The requested module 'module-a' does not provide an export named 'default'
Importing a module that has no default export using import without cache.
fix
Use named imports matching the module's exports. This is unrelated to cache busting; ensure the module exists.
Error: import-without-cache is not supported in this environment.
Runtime check isSupported returned false (e.g., on Deno or old Node).
fix
Check isSupported before using init, and only call if true. Do not use on unsupported platforms.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
import-without-cache — npm install import-without-cache · libregistry