Aissa El Ouafi Aissa El Ouafi - 8 months ago 27
Node.js Question

Include .css and .js file in Node.js project

I used Node.js and Angular.js to build a simple web application based on Express framework, when I try to upload a

file, I got the following error message :

“The stylesheet was not loaded because its MIME type, ”text/html“ is not ”text/css"


var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var pg = require('pg');
var jwt = require('jsonwebtoken'); // create, sign and verify tokens
var morgan = require('morgan');
// Application front end
console.log('LogAnalysisWebApp happens on port '+port);


<!DOCTYPE html>
<html lang="fr">
<meta charset="utf-8">
<title>Log Analysis Web APP</title>
<link rel="stylesheet" type="text/css" href="/public/stylesheets/style.css">
<h1>Text Example</h1>

My project has the following structure :

Project structure


To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.


Now, you can load the files that are in the public directory:

Here is the official documentation page on serving static resources.