import-without-cache
Import ES modules without cache.
Last updated 2 months ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install import-without-cache 
SYNC missed versions from official npm registry.

import-without-cache

npm version npm downloads Unit Test

Import ES modules without cache.

Features

  • Import ES modules without cache
  • All dependencies are also imported without cache

Install

npm i import-without-cache

Usage

import { clearRequireCache, init, isSupported } from 'import-without-cache'

if (!isSupported) {
  throw new Error('import-without-cache is not supported in this environment.')
}

const deregister = init({
  // Optional
  skipNodeModules: false,
})

const mod = await import('some-module', { with: { cache: 'no' } })

clearRequireCache() // Optional: clear CommonJS cache if needed

// or
const mod2 = await import(`no-cache://some-module`)

expect(mod).not.toBe(mod2) // Different instances

deregister() // Optional: deregister the hooks when no longer needed

Known Limitations

  • Supports Node.js v22.18.0 and later; Deno is not supported.
  • Yarn PnP is not supported on Node.js versions earlier than v24.
  • In Bun, clearRequireCache works, but init is unnecessary because ESM imports behave the same as CommonJS requires.
  • Only ESM modules are supported by default. The CommonJS cache can be cleared with clearRequireCache.
  • require(esm) is supported starting in Node.js v24.13.1.

Sponsors

License

MIT License © 2025-PRESENT Kevin Deng

Current Tags

  • 0.4.1                                ...           latest (2 months ago)

16 Versions

  • 0.4.1                                ...           2 months ago
  • 0.4.0                                ...           7 months ago
  • 0.3.3                                ...           7 months ago
  • 0.3.2                                ...           7 months ago
  • 0.3.1                                ...           7 months ago
  • 0.3.0                                ...           7 months ago
  • 0.2.5                                ...           a year ago
  • 0.2.4                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Total 51
Today 0
This Week 17
This Month 35
Last Day 7
Last Week 16
Last Month 16
Dependencies (0)
None
Dev Dependencies (10)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE