Registry / devops / deep-require

deep-require

JSON →
library0.0.9jsnpmunverified

Require all files within a directory with support for filtering, mapping, parsing, and dash-to-camelCase conversion. Version 0.0.9 is the latest stable release; it is a small utility library that works with transpiler runners using require-extensions and supports NODE_PATH. It offers recursive scanning with a flat option and partially applicable configuration. Differentiators include built-in camelization and extensible extensions list compared to similar directory require tools.

npm install deep-require
INSTALL
IMPORT
SIG · DEEP-REQUIRE
D
deep-require
devopsjavascriptv0.0.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

deepRequire (default export)
const deepRequire = require('deep-require')
import deepRequire from 'deep-require'
Package uses CommonJS and does not provide ESM exports. Default export is a function that returns a function when called with options.

Shows how to require a directory with filtering, camelization, and custom map function.

const path = require('path'); const deepRequire = require('deep-require'); const getModels = deepRequire({ camelize: true, filter: /\.model\.js$/, recursive: false, extensions: ["js", "json"] }); const models = getModels('./models'); console.log(models);
Debug
Known issues
gotchaThe default export is a curried function: calling deepRequire(options) returns a function that accepts a directory path. Forgetting to call the returned function results in a function object, not the required modules.
fix
Ensure you invoke the returned function: const modules = deepRequire(options)(dir);
affects: >=0.0.0
gotchaThe package does not support asynchronous directory searching; all operations are synchronous.
fix
Do not use in performance-critical or large-directory contexts; consider alternatives like glob or fs.readdirSync wrapper.
affects: >=0.0.0
gotchaThe 'recursive' option does not search subdirectories by default; set recursive: true for recursion or recursive: 'flat' for flattened results.
fix
Pass recursive: true or recursive: 'flat' in options.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: deepRequire is not a function
Misunderstanding of curried interface: calling deepRequire(options) returns a function, not the modules.
fix
Invoke the returned function with a directory path: const result = deepRequire(options)(dir);
Cannot find module 'deep-require'
Package not installed or incorrect import path.
fix
Run npm install deep-require --save and ensure the require path is correct.
ENOENT: no such file or directory, scandir './models'
The directory passed to the inner function does not exist.
fix
Check that the directory path is correct and exists relative to the current working directory.
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
deep-require — npm install deep-require · libregistry