Search code examples
node.jsgruntjsuglifyjs

How to get Grunt working..?


I have read a lot of different posts before asking here but I can't get through that error "Uglify not found"..

I have downloaded node.js, uglfy.js.. Shortly I have followed all the steps here.. How to install grunt and how to build script with it

my Gruntjs file:

module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            build: {
                src: 'js/global.js',
                dest: 'js/build/global.min.js'
            }
        }
    });

    // Load the plugin that provides the "uglify" task.
    grunt.loadNpmTasks('grunt-contrib-uglify');

    // Default task(s).
    grunt.registerTask('default', ['uglify']);
};

and package.json:

{
    "name": "contentImageSlider",
    "version": "0.1.0",
    "devDependencies": {
        "grunt": "^0.4.5",
        "grunt-contrib-concat": "^0.4.0",
        "grunt-contrib-jshint": "~0.10.0",
        "grunt-contrib-nodeunit": "~0.3.3",
        "grunt-contrib-uglify": "~0.4.0"
    },
    "description": "slider",
    "main": "Gruntfile.js",
    "dependencies": {
        "grunt": "^0.4.5"
    },
    "scripts": {
        "test": "test"
    },
    "repository": {
        "type": "git",
        "url": "https://github.com/haldunatar/contentImageSlider.git"
    },
    "author": "",
    "license": "ISC",
    "bugs": {
        "url": "https://github.com/haldunatar/contentImageSlider/issues"
    },
    "homepage": "https://github.com/haldunatar/contentImageSlider"
}

Error :

Local Npm module "grunt-contrib-uglify" not found. is it installed?
Warning:Tast 'uglify' not found. use --force to continue.

Aborted due to warnings.

So every time as I enter "grunt", it gives that error..but I downloaded uglify.js..

Can anybody help me here?

Thanks in advance!


Solution

  • I see that the "grunt-contrib-uglify" is in your package.json file, but the error indicates it's not installed. Perhaps you recently added the dependency but did not perform an npm install? Try running npm install from the root directory, then re-running grunt.