Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-autorequire

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-autorequire

a shim to require a module and npm install it if not found

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

node-autorequire

A little module to facilitate easier require() calls

usage

instead of doing a bunch of npm install --save {package} calls, just do one:

npm install --save node-autorequire

Then, in any script do:

const autoRequire = require('node-autorequire')(), someDep = autoRequire('some-dependency');

Now, when you run your master script, if some-dependency isn't found, it's installed and then returned back to the calling script, synchronously.

Why call it as a function?

The node-autorequire export is a generator function. You call it to get a 'require-like' function. Without any arguments, packages are just installed, nothing more. You can configure to --save-dev by providing { saveDev: true } or --save with { save: true }. Normally, I find that this works well -- production code always wants a save and test code always wants a saveDev.

YMMV

FAQs

Package last updated on 11 Jun 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc