Socket
Socket
Sign inDemoInstall

import-fresh

Package Overview
Dependencies
3
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    import-fresh

Import a module while bypassing the cache


Version published
Weekly downloads
40M
decreased by-5.55%
Maintainers
1
Install size
22.4 kB
Created
Weekly downloads
 

Package description

What is import-fresh?

The import-fresh npm package is used to import a module afresh, bypassing the cache that Node.js uses for require calls. This is particularly useful when you need to ensure that you're getting a fresh version of the module, for instance, when you're testing or when you want to reload configuration files that may have changed.

What are import-fresh's main functionalities?

Bypass require cache

This feature allows you to bypass the require cache and freshly import a module. It's useful when you want to reload a module to reflect any changes made to it since it was first imported.

const importFresh = require('import-fresh');
const freshConfig = importFresh('./config');

Other packages similar to import-fresh

Readme

Source

import-fresh Build Status

Import a module while bypassing the cache

Useful for testing purposes when you need to freshly import a module.

Install

$ npm install import-fresh

Usage

// foo.js
let i = 0;
module.exports = () => ++i;
const importFresh = require('import-fresh');

require('./foo')();
//=> 1

require('./foo')();
//=> 2

importFresh('./foo')();
//=> 1

importFresh('./foo')();
//=> 1
  • clear-module - Clear a module from the import cache
  • import-from - Import a module from a given path
  • import-cwd - Import a module from the current working directory
  • import-lazy - Import modules lazily

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 25 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc