Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Grunt Named Modules

Allows you to specify aliases for your module paths

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-named-modules --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:


The "namedModules" task


For now, this task has no options and assumes you're using a package.json file. In your package.json file, add a new directive called namedModules:

  "scripts": {
    "postinstall": "grunt namedModules"
  "namedModules": {
    "utils": "lib/utils.js",
    "errors": "lib/errors.js",
    "middleware": "lib/middleware/index.js",
    "configs": "configs/" // <-- alias a directory

The name of the module will be the key, and the full module path is the value. Now, anywhere in your code, you can just require the alias:

var utils   = require('utils');
var errors  = require('errors');
var m       = require('middleware');
var aConf   = require('configs/a');

I would just put a watch on my package.json:

watch: {
  namedModules: {
    files: ['package.json'],
    tasks: ['namedModules'],
    options: {
      spawn: false,


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

1.0.2 - Added directory support 1.0.1 - The initial release!


Allows you to specify aliases for your module paths




No packages published
You can’t perform that action at this time.