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
43M
decreased by-0.25%
Maintainers
1
Install size
23.6 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

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

import-fresh for enterprise

Available as part of the Tidelift Subscription.

The maintainers of import-fresh and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

  • 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

Keywords

FAQs

Last updated on 20 Dec 2020

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