Sails: Grunt fails in production mode

Created on 26 Nov 2014  路  9Comments  路  Source: balderdashy/sails

When I set my environment to 'production', I get the following error when attempting sails lift:

data:    app.js:8674 - ** Grunt :: An error occurred. **
data:    app.js:8674 - error: 
data:    app.js:8674 - ------------------------------------------------------------------------
data:    app.js:8674 - Aborted due to warnings.
data:    app.js:8674 - Running "uglify:dist" (uglify) task
data:    app.js:8674 - { message: 'Name expected',
data:    app.js:8674 -   line: 5976,
data:    app.js:8674 -   col: 3,
data:    app.js:8674 -   pos: 338160,
data:    app.js:8674 -   stack: 'Error\n    at new JS_Parse_Error (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:189:18)\n    at js_error (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:197:11)\n    at croak (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:660:41)\n    at as_symbol (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1275:27)\n    at vardefs (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1056:25)\n    at var_ (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1070:27)\n    at /home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:818:30\n    at /home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:703:24\n    at block_ (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:977:20)\n    at /home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:950:25\n    at function_ (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:955:15)\n    at expr_atom (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1158:24)\n    at maybe_unary (/home/damon/bin/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1327:19)' }
data:    app.js:8674 - >> Uglifying source .tmp/public/concat/production.js failed.
data:    app.js:8674 - Warning: Uglification failed.
data:    app.js:8674 - Name expected. 
data:    app.js:8674 - Line 5976 in .tmp/public/concat/production.js

Changing to development results in Sails lifting without issue.

I've tried making sure all the deps are installed with npm install, and also checked the permissions are correct on .tmp/.

Running sails-0.10.5.

needs better error message needs documentation question

Most helpful comment

Thank you for the quick response @wyqydsyq unfortunately it did not work. I've tried everything else, changing the permissions in .tmp, npm install, checking for errors in all other assets. It runs smoothly when I do "sails lift" but when I run "node app.js --prod" I always get the same error.
EDIT: I finally got it to work but I had to comment almost everything out from grunt:

tasks -> register -> prod.js
module.exports = function(grunt) { grunt.registerTask('prod', [ 'compileAssets', // 'concat', // 'uglify', // 'cssmin', // 'sails-linker:prodJs', // 'sails-linker:prodStyles', // 'sails-linker:devTpl', // 'sails-linker:prodJsJade', // 'sails-linker:prodStylesJade', // 'sails-linker:devTplJade' ]); };
Don't know if this is good or bad but it finally lifted.

All 9 comments

Any progress on this? I am seeing exactly the same error. Lifting sails with any other environment variable setting works fine, but sails won't lift in production.

I finally just figured it out after days: I needed to explicitly have grunt listed as a dependency of my project. Weird that this is necessary in production but not other environments.

does @lsvx comment resolve the question? Is this still an issue? Can we close this up?

I am having the same issue. I don't think it should be closed. I think it should be fixed!

I agree with nheinbaugh, especially since we are working on the same project. We have grunt listed as a dependency in the package.json file, but are getting grunt-related errors, similar to the one posted above. We are getting grunt errors related to the assets compiling and linking tasks. When we remove those from the tasks > register > defaults.js file, Sails lifts normally.

Thanks for posting, @wyqydsyq. I'm a repo bot-- nice to meet you!

It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:

  • review our contribution guide to make sure this submission meets our criteria (only _verified bugs_ with documented features, please; no questions, commentary, or bug reports about undocumented features or unofficial plugins)
  • create a new issue with the latest information, including updated version details with error messages, failing tests, and a link back to the original issue. This allows GitHub to automatically create a back-reference for future visitors arriving from search engines.

Thanks so much for your help!

Hello everyone, I am unfortunately seeing this same error, @lsvx if it's not too much trouble, could you please tell me how to explicitly have grunt listed as a dependency of my project? Thank you so much.

@Cris87 npm install grunt --save should work

Thank you for the quick response @wyqydsyq unfortunately it did not work. I've tried everything else, changing the permissions in .tmp, npm install, checking for errors in all other assets. It runs smoothly when I do "sails lift" but when I run "node app.js --prod" I always get the same error.
EDIT: I finally got it to work but I had to comment almost everything out from grunt:

tasks -> register -> prod.js
module.exports = function(grunt) { grunt.registerTask('prod', [ 'compileAssets', // 'concat', // 'uglify', // 'cssmin', // 'sails-linker:prodJs', // 'sails-linker:prodStyles', // 'sails-linker:devTpl', // 'sails-linker:prodJsJade', // 'sails-linker:prodStylesJade', // 'sails-linker:devTplJade' ]); };
Don't know if this is good or bad but it finally lifted.

Was this page helpful?
0 / 5 - 0 ratings