Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
No enviará console.log a la terminal

Estoy tratando de aprender los conceptos básicos de node.js y estoy siguiendo un tutorial en youtube, pero mi código no se envía a la terminal cuando voy a localhost: 3000.

Aquí está mi código:

aplicación.js

 var express = require("express"); var path = require("path"); var routes = require("./routes"); var app = express(); app.set("port", process.env.PORT || 3000); app.use(routes); app.listen(app.get("port"),function(){ console.log("Server started on port " + app.get("port")); });

rutas.js

 var express = require("express"); var router = express.Router(); router.get("/", function(req,res){ console.log("Hello I'm on the start page here"); //res.render("index"); }); module.exports = router;

¿Puede alguien explicar por qué?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En app.js intente esto: -

 const express = require("express"), path = require("path"), routes = require("./routes"), app = express(), port = process.env.PORT || 3000, host = process.env.HOST || 127.0.0.1; app.use(routes); app.listen(port, host, (err) => { if(err) console.log(`Some error has occured due to: ${err}`); console.log(`The server has started on http://${host}:${port}/`); });

Para rutas.js: -

 const router = require("express").Router(); router.get("/", (req, res) => { console.log("The home page of this web app."); res.status(200).send("Home"); });

No estoy 100% seguro de que esto funcione.

¡Gracias!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!