Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use grunt-html installed globally?

I would like to use grunt-html task to check my HTML files.

I install the task locally with npm install grunt-html and use it in grunt.js as follows:

module.exports = function (grunt) {

    grunt.loadNpmTasks('grunt-html');

    grunt.initConfig({

        htmllint:{
            all:['*.html']
        },

    });

};

Now I would like to install the grunt-html task globally.

Unfortunately after removing the local grunt-html node module and installing it globally grunt fails to load the task. While running grunt htmllint I get:

>> Local Npm module "grunt-html" not found. Is it installed?

If I remove grunt.loadNpmTasks('grunt-html'); from the grunt.js file I get:

 Task "htmllint" not found. Use --force to continue. 

So my question is how to use grunt-html installed globally?

like image 370
Michael Avatar asked Aug 26 '12 13:08

Michael


People also ask

How do I run grunt locally?

Installing grunt-cli locally If you prefer the idiomatic Node. js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev . Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .


1 Answers

gruntjs doesn't currently support loading globally-installed grunt modules from loadNpmTasks, per the documentation of grunt.loadNpmTasks:

This plugin must be installed locally via npm, and must be relative to the grunt.js gruntfile.

Of course, if you really insist on installing it globally, a hack would be to create a symlink (ln -s) from your local node_modules directory to your global node_modules/grunt-html directory.

If you're doing module development, another alternative would be to use the under-appreciated npm link command that lets you locally install a module that exists elsewhere on you system (see npm help link for usage information).

Both of these approaches, though, don't allow you to truly install the grunt-html package globally.

like image 176
smithclay Avatar answered Nov 01 '22 01:11

smithclay