Skip to content

Instantly share code, notes, and snippets.

@amomin
Last active November 1, 2015 16:47
Show Gist options
  • Save amomin/525fd0adba893668e538 to your computer and use it in GitHub Desktop.
Save amomin/525fd0adba893668e538 to your computer and use it in GitHub Desktop.
Notes on an error in building a meanjs project for production

Building production on a mean.js stack application

By mean.js I mean specifically an application based on the meanjs framework hosted here.

For reference, the following posts helped me identify and fix my problem.

It works mostly like how you would expect. From a vanilla working development environment, the following should work:

grunt build
NODE_ENV=production grunt build

And then you can run your app in production mode via

NODE_ENV=production grunt

The following should also work:

NODE_ENV=production node server.js

However, if you added some external libraries during development, the above may not work. For example, if you added some libraries to your config/env/all.js file, you may need to add the to your config/env/prod.js file (despite this being called "all.js"). Here's a concrete example (config/env/all.js):

module.exports = {                                                                   
    app: {                                                                           
      ...
    },
    ...
    assets: {                                                                        
        lib: {                                                                       
            css: [
              ...
            ],
            js: [
                'public/lib/angular/angular.js',
                'public/lib/angular-resource/angular-resource.js',
                'public/lib/angular-ui-router/release/angular-ui-router.js',         
                'public/lib/angular-ui-utils/ui-utils.js',                           
                'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',                 
                'public/lib/ng-file-upload/ng-file-upload-shim.min.js', //added library              
                'public/lib/ng-file-upload/ng-file-upload.min.js', //added library
            ]                                                                        
        },

Be sure to add these to config/env/prod.js as well:

module.exports = {                                                                   
    ...
    assets: {                                                                                                       
        lib: {                                                                           
            css: [                                                                   
              ...
            ],                                                                       
            js: [                                                                    
                'public/lib/angular/angular.min.js',                                 
                'public/lib/angular-resource/angular-resource.js',                   
                'public/lib/angular-ui-router/release/angular-ui-router.min.js',     
                'public/lib/angular-ui-utils/ui-utils.min.js',                       
                'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',                 
                'public/lib/ng-file-upload/ng-file-upload-shim.min.js', // add here too
                'public/lib/ng-file-upload/ng-file-upload.min.js',  // add here too
            ]                                                                        
        },                                                          
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment