Getting "TypeError: Router.use() requires a middleware function but got a Object at Function" for this challenge

Tell us what’s happening:
Describe your issue in detail here.

No matter what I do for this problem I’m getting errors on Replit and locally (VSCode). From both I’m getting:

TypeError: Router.use() requires a middleware function but got a Object
at Function.use (/home/runner/boilerplate-express-1/node_modules/express/lib/router/index.js:458:13)

The code is really simple so I’m (somewhat) doubtful that it’s myApp.js.

Your code so far

var express = require('express');

var app = express();

app.get("/", (req, res) => {

res.send("Hello Express");

});

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Challenge: Start a Working Express Server

Link to the challenge:

You seem to have removed the export from the bottom of the file.

var express = require('express');
var app = express();

app.get("/", (req, res) => {
  res.send("Hello Express");
});

module.exports = app;

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Much thanks but when I pulled the latest from the repo last night I didn’t see that line in myApp.js. Was it supposed to be there? EDIT: I overwrote it from the repo. Just checked this morning.

Got it about the back ticks. Same thing as markdown.

Thanks again!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.