New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

require-grep

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-grep

Minimal NodeJS module finder with grepping capabilities

latest
Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
6
-25%
Maintainers
1
Weekly downloads
 
Created
Source

require-grep

Minimal NodeJS module finder with grepping capabilities.

In its simplest invocation this will return a list of paths (require() ready) that match the string, regexp or filter expression given.

var requireGrep = require('require-grep');

// Find the globally installed version of lodash
requireGrep('lodash', function(err, path) {
	// Path will be something like "/usr/lib/node_modules/lodash"
});

// Find all globally installed lodash plugins
requireGrep(^lodash-/, {multiple: true}, function(err, paths) {
	// Paths will be an array of found global module directories
});

Why

There are already quite a selection of modules that can find modules. But they have a variety of weird bugs, are unmaintained or rely on far too many weird-and-wonderful dependencies in order to do what is a relatively simple task - finding a module.

This module is intended to be as brain-dead as possible - doing only one single thing - returning a list of modules matching a grep.

Options

OptionDefaultDescription
callbackthe last argumentThe callback to invoke with (err, foundPath) parameters
grepsthe first argumentAn array of grep expressions to search by. These can be strings, regExps or functions
localtrueSearch the local directory for modules
globalfalseSearch all global paths for modules
globalPathsprocess.env.NODE_PATHThe global paths to search
localPaths./node_modulesThe local paths to search
multiplefalseShortcut property to set {failNone: false, failOne: false, failMultiple: false, array: true}
failNonetrueReturn an error if no modules were found
failOnefalseReturn an error if only one module was found
failMultipletrueReturn an error if multiple modules were found
failDirErrfalseReturn an error if any of the module search paths raise an error. False will fail silently (recommended)
failDirStatfalseReturn an error if any of the module search paths fail to stat. False will fail silently (recommended)
failDirJSONfalseReturn an error if any of the candidate modules do not have a valid JSON file. False will fail silently (recommended)

Keywords

require

FAQs

Package last updated on 24 Jul 2017

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