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.
- https://stackoverflow.com/questions/24516497/how-to-deploy-mean-js-node-js-application-to-production-environment
- https://blog.dylants.com/2014/11/19/bundling-production-assets-for-mean-js/
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
]
},