node package manager


Grunt task to automatize the use of browserify for NPM modules in your AMD/RequireJS projects.

Getting Started

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, install this plugin with this command:

npm install grunt-npm-amd --save-dev

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


Example usage

    npm_amd: {
        target: {
            config: 'app/config.js'
grunt.registerTask('default', ['npm_amd']);


When the npm_amd task is run it bundles installed NPM modules with browserify via NPM-AMD and merges the bundle paths into the paths property of your AMD config file. Also it will detect AMD entries and just point the configuration to it, instead of doing pointless browserifying ;)

You trigger this task from another task in your Gruntfile or through the CLI: grunt npm_amd

Note: The default options work for RequireJS-compatible config files, such as the ones for RequireJS and curl, but you can tune it to work with pretty much anything.


Type: String

Specify a relative path to your RequireJS config.

Make sure to specify the baseUrl property in your config file if you want to use relative paths.


Optional Type: Object Default:

  baseUrl: "baseUrl",
  paths: "paths"

Property names to look for when patching up the config file. Declare this to support other AMD loaders.

NPM-AMD options.

Watch that space.

Things to remember

  • You need to already have a config file at the location specified by config. For example, for RequireJS you need to have at least the following:
  • The task does not overwrite the config file, it just adds additional paths to it. So paths you add will be preserved. Keep in mind that if you change or remove one of your NPM dependencies after you've run the task, that path will still exist in the config file and you'll need to manually remove it.