
Security News
curl Shuts Down Bug Bounty Program After Flood of AI Slop Reports
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.
load-modules
Advanced tools
Load the resolved paths to npm modules, directly or in your project's Grunt config using Underscore/Lo-Dash templates.

Load the resolved paths to npm modules, either directly or in your project's Grunt config using Underscore/Lo-Dash templates.
Depends on matchdep by @tkellen.
Install the module with: npm install load-modules --save
var load = require('load-modules').load(pattern, config);
console.log(load);
var load = require('load-modules');
// Resolve paths to all dependencies from package.json
require('load-modules').load('foo*');
// Resolve paths to all devDependencies
require('load-modules').loadDev('bar-*');
// Resolve paths to both dependencies and devDependencies
require('load-modules').loadAll('*-baz'));
// Resolve the path to a specific module
require('load-modules').filepath('module-to-resolve');
Based on the dependencies of this project, the following:
console.log(require('load-modules').load('*'));
would return:
[
"node_modules/lodash/dist/lodash.js",
"node_modules/matchdep/lib/matchdep.js",
"node_modules/minimatch/minimatch.js",
"node_modules/chalk/chalk.js"
]
To resolve the path to a specific npm module:
console.log(require('load-modules').filepath('lodash'));
would return:
node_modules/lodash/dist/lodash.js
To mixin the methods from load-modules using default:
grunt.util._.mixin(require('load-modules'));
Add the following to your Grunt config:
module.exports = function (grunt) {
// Use as a mixin with lodash templates, so that resolved npm modules
// are loaded directly into src file patterns in Grunt tasks
grunt.util._.mixin(require('load-modules'));
grunt.initConfig({
// Load resolved paths to all pkg.dependencies into foo property
foo: grunt.template.process('<%= _.load("*") %>')
// results in (using the deps from this repo as an example):
// node_modules/lodash/dist/lodash.js,
// node_modules/matchdep/lib/matchdep.js,
// node_modules/minimatch/minimatch.js,
// node_modules/chalk/chalk.js
});
grunt.registerTask('default', ['assemble']);
};
Or customize the mixins or mixin aliases:
module.exports = function (grunt) {
grunt.util._.mixin({
foo: function(pattern, config) {
return require('load-modules').load(pattern, config);
},
bar: function(config) {
return require('load-modules').loadDev('pattern', config);
},
baz: function(pattern, config) {
return require('load-modules').loadAll(pattern, config);
}
});
grunt.initConfig({
// Check your config
baz: console.log(grunt.template.process('<%= _.baz("*") %>')),
});
grunt.registerTask(...);
};
module.exports = function (grunt) {
// Customize the mixin to use in templates
grunt.util._.mixin({
resolve: function(pattern, config) {
return require('load-modules').load(pattern, config);
}
});
console.log(grunt.util._.resolve('*')); // show deps in command line
grunt.initConfig({
assemble: {
options: {
helpers: ['<%= _.resolve("my-helpers-*") %>'],
partials: ['<%= _.resolve("my-partials-*") %>'],
data: ['<%= _.resolve("my-data-*") %>']
},
site: {
src: ['src/*.hbs'],
dest: 'dist/'
}
},
// assemble-less Grunt plugin
less: {
options: {
imports: {
reference: ['<%= _.resolve("my-mixins") %>']
}
},
styles: {
files: {
'css/styles.css': ['less/*.less']
}
}
}
});
grunt.registerTask('default', ['assemble']);
};
Jon Schlinkert
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
Copyright (c) 2013 Jon Schlinkert, contributors. Licensed under the MIT license.
FAQs
Load the resolved filepaths to npm modules, either directly in your config or from Underscore/Lo-Dash templates.
The npm package load-modules receives a total of 0 weekly downloads. As such, load-modules popularity was classified as not popular.
We found that load-modules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.