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
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.
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.