nodejs express app deploying to production

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-21 12:07:37

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/38651764/nodejs-express-app-deploying-to-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!