temp-require v1.0.0
req (temp-require)
Req requires npm packages dynamically.
If the package is not found, it is installed from npm to a temporary directory and then required.
Installation
npm install temp-require
Usage
const req = require('temp-require');
const _ = req('lodash');
How it Works
When you call the req
function with a package name, it first attempts to require the package normally. If the package is not found, it then attempts to require it from a temporary directory. If the package is still not found, it downloads the package from npm, installs it in the temporary directory, and then requires it.
This allows you to quickly test out npm packages without having to install them permanently in your project. The temporary directory is located in your system's temp folder, so the installed packages do not interfere with your project's node_modules directory or package.json file.
Author
Varun A
License
MIT
11 months ago