Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs express app deploying to production

Sorry if this is a basic question, I am still wrapping my head around nodejs deployments. I have an app written on nodejs which I want to deploy to production. So far for testing purposes I have used Express. However from what I know Express is a dev server and not a production server. How do I deploy the nodejs app to production and what is the server I should use. Plus I have a lot of code written for express like routes and middleware, how does this work when I deploy to another server?

like image 201
user3547774 Avatar asked Jul 29 '16 06:07

user3547774


People also ask

Is Expressjs good for production?

It's fast, unopinionated, and has a large community behind it. It is easy to learn and also has a lot of modules and middleware available for use. Express is used by big names like Accenture, IBM, and Uber, which means it's also great in a production environment.

How do I deploy a Nodejs application to render?

You can also add your . env files so you don't need to enter them manually one by one. Note that, the Auto-Deploy field has default value of Yes – so once you push your code changes to GitHub repository, they will be automatically deployed to Render.


1 Answers

When you create your application with express.js, all express modules have been specified in package.json and will be installed as npm modules.

All you need to do is just install node.js on your production servers, put your code there, run npm install, then start the web server with NODE_ENV=production param. It would be a plus if you can use grunt or gulp to process static assets (js / css minification, ...) to optimize the performance for production mode.

For more information, you can take a look here: https://expressjs.com/en/advanced/best-practice-performance.html

like image 83
haotang Avatar answered Sep 19 '22 23:09

haotang