Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt uglifym - call stack size exceeded

Tags:

gruntjs

I am trying to use uglify with grunt to concat and minify some files. I have already used the npm to install grunt-contrib-uglify.

I have the following in my grunt.js file: (I have removed some other tasks for anonymity)

module.exports = function(grunt) {

  'use strict';      

    grunt.loadNpmTasks('grunt-contrib-uglify');

    uglify: {
        options: {
            sourceMap: 'app/map/source-map.js'
        },
        files: {
            'app/dist/sourcefiles.min.js': [
                'app/test_js/test.js'
              ]
        }
    }

};

I then run:

grunt uglify

but I keep getting the following error:

Warning: Maximum call stack size exceeded Use --force to continue.

If I use force, the grunt task never stops running.

Can someone tell me where I am going wrong? I am tearing my hair out on this one.

like image 207
John Green Avatar asked Dec 09 '22 15:12

John Green


2 Answers

I had the same problem, using an other Grunt plugin called recess. The error message was not explicit.

Warning: Cannot read property 'message' of undefined Use --force to continue.

But the verbose mode showed that my task was called hundred of times. The problem was that I created a "cyclic dependency" (causing an infinite loop) when I registered my task.

grunt.registerTask('recess', ['recess']); //does not work => cyclic dependency! 

The first parameter of registerTask method is an "alias task" and has to be different from the task names defined in the second parameter. I corrected like this:

grunt.registerTask('my-recess-task', ['recess']);

And I runned the task calling this (in the Command prompt window)

grunt my-recess-task

And then it was OK!

More about registerTask() method, from grunt API: http://gruntjs.com/api/grunt.task#grunt.task.registertask

like image 186
Michael Rambeau Avatar answered Jan 12 '23 05:01

Michael Rambeau


I also met this problem, i solved this by removing grunt.registerTask('uglify', ['uglify']);

before i solved this, i ran grunt uglify -v to check what happend.

I found it because that where you using this grunt.loadNpmTasks('grunt-contrib-uglify'); ,it implicitly executes the grunt.registerTask('uglify', ['uglify']); ^_^

like image 37
Victor Avatar answered Jan 12 '23 06:01

Victor