Search code examples
javascriptnode.jscoffeescriptuglifyjs

Error with "cake build:browser" and Uglify.js -- Cannot read property 'Array' of undefined


I just installed Uglify.js and tried to use it to rebuild CoffeeScript, but keep getting this error. This happens when I type "cake build:browser" in the CoffeeScript directory. (I want to try my hand at modifying the CoffeeScript language.)

My Uglify.js was cloned from GitHub and the symbolic link was created in .node_libraries. Uglify is installed correctly, confirmed since it runs properly in Node and through the command line. So maybe this is a CoffeeScript problem.

Help?

/Users/myuser/projects/UglifyJS/lib/process.js:475
                        return options.defines[name];
                                              ^
TypeError: Cannot read property 'Array' of undefined
    at get_define (/Users/myuser/projects/UglifyJS/lib/process.js:475:47)
    at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:527:32)
    at walk (/Users/myuser/projects/UglifyJS/lib/process.js:215:47)
    at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:164:59)
    at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
    at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:146:43)
    at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
    at /Users/myuser/projects/UglifyJS/lib/process.js:1643:37
    at Array._block (/Users/myuser/projects/UglifyJS/lib/process.js:81:34)
    at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)

Solution

  • OK, I was able to replicate this. But why are you cloning the UglifyJS repo? If you just do npm install uglify-js to install to the local node-modules directory (with npm 1.x), everything runs fine.

    Similar issue: https://github.com/mishoo/UglifyJS/issues/140