1

I wanted to know standard process to deploy nodejs app on production. As of now I am following the process as below

Pull the source code

git pull git_url

Install npm dependencies

npm install 

Build the code

npm run build

run the application

nohup node server/index.js &

But I am thinking of pulling source code to prod is the totally wrong way. Please, someone, guide me the exact way to deploy node app on the production server. Also, any other way to run the app continuously as service. I am aware with pm2 module to run a process in the backend. If there is any other way to manage it properly.

  • "But I am thinking of pulling source code to prod is the totally wrong way" Why not, as long as you don't pull from a dev or unstable branch. In common branching strategies, master is considered as the "production ready" branch so you should pull from it and nothing else. – Sylvain Leroux Feb 12 at 11:36
  • On a differnt topic, are you deploying on a bare metal server, or in some virtual environent, container or VM? – Sylvain Leroux Feb 12 at 11:37
  • Thanks @SylvainLeroux. I am not sure about js exactly. But as in java we are creating artifact like .war . I thought with npm run build we are creating the same. ( as it is creating some build directory). Can you tell me is there anything like this in nodejs – Sunil Bhoi Feb 12 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.