javascriptnode.jsgruntjsgrunt-contrib-cssmin

Error on creating minified css with grunt-contrib-cssmin


I have an issue when I try to create minified css with grunt-contrib-cssmin. SourceMaponcssmin.js` is set as false and I can't find why I keep getting this error message.

What should I do with this ./source-map/source-map-generator" error?

Error message

Loading "cssmin.js" tasks...ERROR
>> Error: Cannot find module './source-map/source-map-generator'

Gruntfile.js

grunt.initConfig({
    cssmin: {
        target: {
            files: [{
                expand: true,
                cwd: 'css',
                src: ['*.css', '!*.min.css'],
                dest: 'css',
                ext: '.min.css'
            }, {
                expand: true,
                cwd: 'css',
                src: ['*.css', '!*.min.css'],
                dest: 'mw/css/',
                ext: '.min.css'
            }]
        }
    },
    watch: {
        cleancss: {
            files: ['*.css', '!*.min.css'],
            tasks: 'cssmin'
        },
    },
});

// Load the plugin
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');

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

Solution

  • try to remove your node_modules folder and re-install your dependencies with npm install. And try to re-run your task