Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

582
Visualizações
how to run a simple node.js file using batch file

I have one simple "Hello World" program in Node.js. I want to run this using batch file.

var http=require("http");

http.createServer(function(request,response){
	response.writeHead(200,{'Content-Type':'text/plain'});
	response.end('Hello World!..\n');
}).listen(8080);
console.log('Server running at http://127.0.0.1:8080/');
I have used this batch file named 'new.bat'.

if not "%minimized%"=="" goto :minimized
set minimized=true
@echo off
start /min cmd /c "C:\Users\USER2\Desktop\webchat\server.js"
goto :EOF
:minimized

please help me.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can try this code to create a batch file:

if not "%minimized%"=="" goto :minimized
set minimized=true
@echo off

cd "C:\app path"

start /min cmd /C "nodemon server.js"
goto :EOF
:minimized

to run node.js in background.

Instead of running your app like you are used to like node server.js, you can use nodemon: nodemon server.js

The most simple way you can imagine for a node package:

npm install -g nodemon
over 4 years ago · Santiago Trujillo Relatório

0

server.js

var http=require("http");

http.createServer(function(request,response){
    response.writeHead(200,{'Content-Type':'text/plain'});
    response.end('Hello World!..\n');
}).listen(8080);
console.log('Server running at http://127.0.0.1:8080/');

new.bat enter image description here

if not "%minimized%"=="" goto :minimized
set minimized=true
@echo off
cd "C:\Users\USER2\Desktop\webchat"

start /min cmd /C "nodemon server.js"
goto :EOF
:minimized

Run the application in cmd: run the application in cmd after running the application in cmd the node.js command prompt will look like this.. the application running successfully now you can see the output in browser by setting localhost and the port

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda