{"_id":"import-fresh","_rev":"4176525","name":"import-fresh","description":"Import a module while bypassing the cache","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-03-01T21:34:42.000Z","created":"2017-05-21T11:39:44.813Z","4.0.0":"2026-02-25T08:03:40.935Z","3.3.1":"2025-02-02T09:45:41.743Z","3.3.0":"2020-12-20T13:35:41.167Z","3.2.2":"2020-11-01T19:03:03.260Z","3.2.1":"2019-11-13T17:09:02.349Z","3.2.0":"2019-11-13T10:39:57.695Z","3.1.0":"2019-06-30T10:01:45.483Z","3.0.0":"2018-12-25T16:23:55.753Z","2.0.0":"2017-05-21T11:39:44.813Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"versions":{"4.0.0":{"name":"import-fresh","version":"4.0.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=22.15"},"scripts":{"test":"xo && node --test tests/*.js && tsd","heapdump":"node heapdump.js"},"keywords":["import","require","cache","uncache","uncached","module","fresh","bypass"],"devDependencies":{"@types/node":"^25.3.0","heapdump":"^0.3.15","tsd":"^0.33.0","xo":"^1.2.3"},"tsd":{"directory":"tests","compilerOptions":{"module":"nodenext","moduleResolution":"nodenext"}},"gitHead":"7bc8025e9d957713eee96c07b88f350cd18940a9","types":"./index.d.ts","_id":"import-fresh@4.0.0","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"shasum":"07057d6f3b6d9bf19b8f287c8d73b43da5f9f289","size":7903,"noattachment":false,"key":"/import-fresh/-/import-fresh-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/import-fresh_4.0.0_1772006620789_0.9687590148164518"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-25T08:03:40.935Z","publish_time":1772006620935,"_source_registry_name":"default","_cnpm_publish_time":1772006620935},"3.3.1":{"name":"import-fresh","version":"3.3.1","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","tsd":"^0.7.3","xo":"^0.23.0"},"_id":"import-fresh@3.3.1","gitHead":"1fad065ac60c08a99d69a6b8a6f5f50e1bcdaaa9","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_nodeVersion":"23.6.1","_npmVersion":"10.9.2","dist":{"shasum":"9cecb56503c0ada1f2741dbbd6546e4b13b57ccf","size":2225,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.3.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/import-fresh_3.3.1_1738489541560_0.3713559391322325"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-02-02T09:45:41.743Z","publish_time":1738489541743,"_source_registry_name":"default","_cnpm_publish_time":1738489541743},"3.3.0":{"name":"import-fresh","version":"3.3.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","tsd":"^0.7.3","xo":"^0.23.0"},"gitHead":"f1dddc06da4f1cdfb44a3aaba1f2c353c00dea02","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@3.3.0","_nodeVersion":"15.4.0","_npmVersion":"6.14.9","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b","size":2332,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.3.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh_3.3.0_1608471341036_0.2255636072835574"},"_hasShrinkwrap":false,"publish_time":1608471341167,"_cnpm_publish_time":1608471341167},"3.2.2":{"name":"import-fresh","version":"3.2.2","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","tsd":"^0.7.3","xo":"^0.23.0"},"gitHead":"cde3c6f4a6f36d18951297a583f19c780dbd2f0b","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@3.2.2","_nodeVersion":"14.11.0","_npmVersion":"6.14.8","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"fc129c160c5d68235507f4331a6baad186bdbc3e","size":2341,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.2.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh_3.2.2_1604257383092_0.8104894692220481"},"_hasShrinkwrap":false,"publish_time":1604257383260,"_cnpm_publish_time":1604257383260},"3.2.1":{"name":"import-fresh","version":"3.2.1","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","tsd":"^0.7.3","xo":"^0.23.0"},"gitHead":"8a7a217edee030110b0412853c64a37f6d055fac","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@3.2.1","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"633ff618506e793af5ac91bf48b72677e15cbe66","size":2326,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.2.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh_3.2.1_1573664942240_0.9935450999499267"},"_hasShrinkwrap":false,"publish_time":1573664942349,"_cnpm_publish_time":1573664942349},"3.2.0":{"name":"import-fresh","version":"3.2.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","tsd":"^0.7.3","xo":"^0.23.0"},"gitHead":"28ab80a357703431d925fc4a852662e85130a476","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@3.2.0","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"fed4d772a13949de7d9894b647e77297db14dedf","size":2209,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh_3.2.0_1573641597593_0.574712556072138"},"_hasShrinkwrap":false,"publish_time":1573641597695,"_cnpm_publish_time":1573641597695},"3.1.0":{"name":"import-fresh","version":"3.1.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","tsd":"^0.7.3","xo":"^0.23.0"},"gitHead":"ed2fcde9acaec943427a6756563a39aeb858d1e8","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@3.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"6d33fa1dcef6df930fae003446f33415af905118","size":2175,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh_3.1.0_1561888905311_0.3754017808551846"},"_hasShrinkwrap":false,"publish_time":1561888905483,"_cnpm_publish_time":1561888905483},"3.0.0":{"name":"import-fresh","version":"3.0.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava","heapdump":"node heapdump.js"},"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"parent-module":"^1.0.0","resolve-from":"^4.0.0"},"devDependencies":{"ava":"^1.0.1","heapdump":"^0.3.12","xo":"^0.23.0"},"gitHead":"0bf56d798cf5f6c845d3f32b5908b2f4e952f7d0","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@3.0.0","_npmVersion":"6.4.1","_nodeVersion":"11.5.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a3d897f420cab0e671236897f75bc14b4885c390","size":1841,"noattachment":false,"key":"/import-fresh/-/import-fresh-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh_3.0.0_1545755035608_0.9390160260884601"},"_hasShrinkwrap":false,"publish_time":1545755035753,"_cnpm_publish_time":1545755035753},"2.0.0":{"name":"import-fresh","version":"2.0.0","description":"Import a module while bypassing the cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/import-fresh.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava","heapdump":"optional-dev-dependency && node heapdump.js"},"files":["index.js"],"keywords":["require","cache","uncache","uncached","module","fresh","bypass"],"dependencies":{"caller-path":"^2.0.0","resolve-from":"^3.0.0"},"devDependencies":{"ava":"*","optional-dev-dependency":"^2.0.1","xo":"^0.18.2"},"optionalDevDependencies":{"heapdump":"^0.3.7"},"xo":{"rules":{"import/no-extraneous-dependencies":"off"}},"gitHead":"db00a4e9b6bb761bd32ab92c0e7955075fbc4e49","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"homepage":"https://github.com/sindresorhus/import-fresh#readme","_id":"import-fresh@2.0.0","_shasum":"d81355c15612d386c61f9ddd3922d4304822a546","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d81355c15612d386c61f9ddd3922d4304822a546","size":1948,"noattachment":false,"key":"/import-fresh/-/import-fresh-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/import-fresh/download/import-fresh-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/import-fresh-2.0.0.tgz_1495366784518_0.4047558819875121"},"directories":{},"publish_time":1495366784813,"_hasShrinkwrap":false,"_cnpm_publish_time":1495366784813}},"readme":"# import-fresh\n\n> Import a module while bypassing the cache\n\nUseful for testing purposes when you need to freshly import a module.\n\n## Requirements\n\n- Node.js 22.15 or later (uses module loader hooks)\n\n## Install\n\n```sh\nnpm install import-fresh\n```\n\n## Usage\n\n```js\n// foo.js\nlet count = 0;\nexport default function increment() {\n\tcount += 1;\n\treturn count;\n}\n```\n\n```js\nimport createImportFresh from 'import-fresh';\n\nconst importFresh = createImportFresh(import.meta.url);\nconst {default: increment} = await importFresh('./foo.js');\n\nincrement();\n//=> 1\n\nincrement();\n//=> 2\n\nconst {default: freshIncrement} = await importFresh('./foo.js');\n\nfreshIncrement();\n//=> 1\n```\n\n## API\n\n### createImportFresh(parentURL, options?)\n\nReturns an `importFresh` function bound to `parentURL`.\n\n`parentURL` must be a valid hierarchical URL string (for example `import.meta.url`) or a `URL` instance.\n\n#### options\n\nType: `object`\n\nThe options are process-global. Every call in the same process must use the same `skipNodeModules` value.\n\n##### skipNodeModules\n\nType: `boolean`\\\nDefault: `false`\n\nWhen `true`, modules inside `node_modules` directories are not cache-busted. This means that dependencies from npm packages will share state across fresh imports, which can be useful when you only want to freshly import your own code.\n\n### importFresh(moduleSpecifier, options?)\n\nThe function returned by `createImportFresh`.\n\n#### options\n\nType: `object`\n\n##### importAttributes\n\nType: `object`\n\nImport attributes passed to `import()`. Each value must be a string. JSON modules are automatically imported with `{type: 'json'}` when the specifier ends with `.json`.\n\n## Caveat\n\nIntended for development usage only. Repeated calls grow the ESM module cache because each call uses a unique cache-busting URL. This is an unavoidable “memory leak” and not considered a vulnerability.\n\n## Related\n\n- [clear-module](https://github.com/sindresorhus/clear-module) - Clear a module from the import cache\n- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path\n- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory\n- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily\n","_attachments":{},"homepage":"https://github.com/sindresorhus/import-fresh#readme","bugs":{"url":"https://github.com/sindresorhus/import-fresh/issues"},"license":"MIT"}