Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run node server with a bat file

I need to create a bat file to start node server, actually we do it manually but some people need extra help. Let me explain the process:

  1. Open CMD
  2. Go to the path: cd C://user/folder/server/
  3. Run the server: npm start

It is very simple but I would really like to automate the process to make it faster.

like image 411
grimaldodev Avatar asked Nov 26 '13 14:11

grimaldodev


People also ask

How do I run a bat program on a Node JS server?

First you must add node.js install folder to path. Last click start.bat Show activity on this post. Just make a bat file in the folder where your program is. Then type this in the bat file: Then, save the bat file and run it.

How do I start a Node JS server?

You can start node.js server as following .bat script file by click on it: Show activity on this post. First you must add node.js install folder to path. Last click start.bat Show activity on this post. Just make a bat file in the folder where your program is. Then type this in the bat file: Then, save the bat file and run it.

How do I start a server with a bat file?

You can start node.js server as following .bat script file by click on it: First you must add node.js install folder to path. Just make a bat file in the folder where your program is. Then type this in the bat file: Then, save the bat file and run it.

How do I launch Node-RED from a batch file?

Double click the batch file to launch Node-Red! 6. If you want the batch file to run every time windows 10 boots copy the batch file or a shortcut to it into C:\Users\ (your user name here)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.


2 Answers

Know this post is old, but just throwing it out there: I just made a super simple .bat-file to start it:

cd C:\nodejs

"C:\MongoDB\bin\mongod.exe" --dbpath C:\MongoDB\bin\data\db

node server.js
like image 189
ddmh Avatar answered Oct 27 '22 18:10

ddmh


Is it just me or is the answer already in plain sight? The following has worked for me perfectly (with OP's path):

cd "C:/user/folder/server"
node index.js
like image 32
Anonymous Avatar answered Oct 27 '22 16:10

Anonymous