skip to Main Content

I have been trying to learn npm recently to use for a website. I am wondering though how it is used in a website, like do you have to run the command "npm start"? How is this integrated in a live website? Like would I have to run "npm start" every time the user enters the main page for example? And if yes, how is this done?

On visual studio code I can easily do it by running "npm start" in the terminal, but I am basically wondering how this is done without visual studio code and in a live website?

2

Answers


  1. During development, we use localhost as a server.

    In real time, a dedicated server will run your program. In this server, you provide instructions on how to start your application.

    Example:- If app.js is the starting point, you provide instructions to start this file.

    If an application is provided as a docker container, the docker file will contain this instruction.
    https://www.geeksforgeeks.org/how-to-call-npm-start-though-docker/

    If an application is deployed to a cloud service provider like Heruko, you customize the instruction as per the service provider.
    https://www.geeksforgeeks.org/deploying-node-js-applications/

    Login or Signup to reply.
  2. I use pm2 to start and keep my node apps running on the server. Using PM2 you can close the terminal and the apps keep running.

    Examples using PM2…

    pm2 start "npm run dev" --name "Your App"
    

    //show running apps

    pm2 status
    

    //show server logs while running apps

    pm2 log
    

    https://pm2.keymetrics.io/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search