Search code examples
node.jsgruntjsnpmyeomanyeoman-generator

Adding additional NPM packages to a yo angular generated project


I've noticed that yo angular generates a GruntFile containing all of the instructions, but typically does not include grunt.loadNpmTasks('<package>') statements, which may or may not be indicative of globally installed packages (?).

So, what is the correct way to add additional NPM packages to a yo-angular generated project?


Solution

  • the yo angular generator uses load-grunt-tasks, which prevents the gruntfile from becoming to bloated:

    This module will read the dependencies/devDependencies/peerDependencies in your package.json and load grunt tasks that match the provided patterns.

    the generator uses load-grunt-tasks without a pattern provided

    require('load-grunt-tasks')(grunt);
    

    which means that it will simply try to load everything (with the pattern grunt-*, for more info see comments below) you install via npm.

    long story short, just npm install it (grunt tasks should be installed with the --save-dev option, to automatically move it to the devDependencies)

    $ npm install your-grunt-task --save-dev