Tell us what’s happening:
I have cloned the GitHub - freeCodeCamp/boilerplate-express: A boilerplate for the freeCodeCamp curriculum. repo to my computer and am running the challenge locally. When I attempt to run the test I get the following error: Root level logger middleware should be active
. I have tried suggestions in previous solutions such as npm update --save
and have modified the code several times with no luck.
Your code so far
let express = require("express");
let dotenv = require("dotenv").config();
let app = express();
app.use((req, res, next) => {
console.log(`${req.method} ${req.path} - ${req.ip}`);
next();
});
app.use("/public", express.static(__dirname + "/public"));
console.log("Hello World");
app.get("/", (req, res) => {
res.sendFile(__dirname + "/views/index.html");
});
app.get("/json", (req, res) => {
let message = "Hello json";
if (process.env.MESSAGE_STYLE === "uppercase") {
message = message.toUpperCase();
}
res.json({ message: message });
});
module.exports = app;
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54
Challenge: Basic Node and Express - Implement a Root-Level Request Logger Middleware
Link to the challenge: