Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Middleware Basics

Brian Crowe
seal-mask
.a{fill-rule:evenodd;}techdegree
Brian Crowe
Full Stack JavaScript v2 Techdegree Student 8,863 Points

If you keep getting a TypeError while trying to run the server...

I kept getting the following error when trying to run the server-side:

"TypeError: Cannot read properties of undefined (reading 'last-modified')"

It kept referencing "fresh" and "serve-static", having a problem accessing the given /public/stylesheets/style.css file. I solved the problem by running the following commands to delete the node_modules and package-lock.json files:

    rm -rf node_modules
    rm package-lock.json

And updating my package.json file to the following:

{
  "name": "understanding-express-middleware-2",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.20.2",
    "debug": "^4.3.4",
    "express": "^4.19.2",
    "pug": "^3.0.3"
  }
}

Then I reran npm install. This updated the dependencies to work with more modern browsers like Brave. I have no experience with other browsers, but I was able to complete the lessons after doing this.

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,740 Points

Updated your question with better syntax highlighting (gave the backticks a hint; e.g. sh or json).