Auto start node.js server on boot

后端 未结 10 1357
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 17:16

Can any node.js experts tell me how I might configure node JS to autostart a server when my machine boots? I\'m on Windows

10条回答
  •  星月不相逢
    2020-11-30 17:34

    If I'm not wrong, you can start your application using command line and thus also using a batch file. In that case it is not a very hard task to start it with Windows login.

    You just create a batch file with the following content:

    node C:\myapp.js
    

    and save it with .bat extention. Here myapp.js is your app, which in this example is located in C: drive (spcify the path).

    Now you can just throw the batch file in your startup folder which is located at C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

    Just open it using %appdata% in run dailog box and locate to >Roaming>Microsoft>Windows>Start Menu>Programs>Startup

    The batch file will be executed at login time and start your node application from cmd.

提交回复
热议问题