Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
Why are styles not being included in index.html on the local server

Using node.js, I opened the server, why is it not showing the styles, although if you just open index.html in the browser, then all the styles are displayed correctly, what is the problem? index.html

<!doctype html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet"  href="style/style.css" type="text/css" />
    <title>Socket.IO chat</title>
</head>

index.js

 const express = require('express');
    const app = express();
    const http = require('http');
    const server = http.createServer(app);
    const port = 3000;
    
    app.use(express.static(__dirname + '/style/style.css'));
    
    app.get('/', (request, response ) => {
        response.sendFile(__dirname + '/index.html');
    });
    
    server.listen(port, () => {
        console.log(`listening on port ${port}`);
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use

app.use(express.static(__dirname + 'style'));

Instead. Express.static uses directories. Not files.

https://expressjs.com/en/starter/static-files.html

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda