Start a Working Express Server - Please Help

Hello,

I don’t know what is wrong with my code. I see no problem with it, but I keep failing the test. Please help.

let express = require('express');

let app = express();

console.log("Hello World");

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

    res.send("Hello Express");

    console.log("Hello Express");

});

console.log("Code After");

module.exports = app;

2 Likes

Hi @jobanibusiness

Try removing the extra console logs, then restart the server.

If that doesn’t work, try using a regular function instead of an arrow function.

Happy coding

2 Likes

I have tried this but I receive the same error. Maybe the file path has to be specific?

let express = require('express');

let app = express();

// console.log("Hello World");




app.get("/", function(req, res){

    res.send("Hello Express");

});




//console.log("Code After");





 

module.exports = app;

Does control C then entering Y restart the server or is it another way to do it?

ctrl-c should be entered until you are back on the terminal.
then you should rerun the npm/node command you used to start

1 Like

I seem to only encounter problems when using VS code to complete the tests. Is there another method to submit these tests?

vscode is an editor. You can use any editor you want. The goal is to run the server though, and that doesn’t change.

1 Like

Well I’m stumped. Tried all suggestions but still no success.

look at the console output in your browser when you are running the test.
The errors there may indicate the issue

1 Like

My guess is that it has to do with something with the other files and not the myApp.js file itself.

look for all occurrences of .use( and see what is happening. Is it possible you messed with the original code given to you? (I assume you didn’t add any that uses use)?

1 Like

For some reason, this line of code was like this in the server.js file I downloaded:

const myApp = require('./myApp').default;

and after comparing it to the one on GitHub I noticed that it didn’t have the default method.

const myApp = require('./myApp');

After I removed it it worked and I got the desired result, but for some reason I am still failing the test.

I made sure to end the server with control + c and starting it up again with npm run start.

I still need help with this.

Hi!
It seems you missed app.listen(3000) at the end of the code.
Just a guess.

1 Like

app.listen(3000) is already in use in the server.js file.

The only clue that I have is this from the console:

Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

Hi @jobanibusiness

See if you can pass the first challenge “Meet the console”.

Otherwise, download the files again. Do not run npm install. Ignore all deprecation warnings.

Do not add any extra console logs. For debugging it is fine.

Happy coding

1 Like

I downloaded the files again and didn’t npm install.

I am still getting errors.

let express = require(‘express’);

let app = express();




app.get("/", function (req, res) {

  res.send("Hello Express");

});

module.exports = app;

Console:

fcc-learn-node-with-express@0.1.0 start C:\Users\Owner\Downloads\boilerplate-express-main
node server.js

internal/modules/cjs/loader.js:883
throw err;
^

Error: Cannot find module ‘fcc-express-bground’
Require stack:

C:\Users\Owner\Downloads\boilerplate-express-main\server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (C:\Users\Owner\Downloads\boilerplate-express-main\server.js:6:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: ‘MODULE_NOT_FOUND’,
requireStack: [
‘C:\Users\Owner\Downloads\boilerplate-express-main\server.js’
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fcc-learn-node-with-express@0.1.0 start: node server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fcc-learn-node-with-express@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Owner\AppData\Roaming\npm-cache_logs\2025-12-08T04_39_10_170Z-debug.log
PS C:\Users\Owner\Downloads\boilerplate-express-main>

Everyone I am going insane