Basic Node and Express - Meet the Node console

Tell us what’s happening:
When I run the code from the local file on my machine, I get the “Hello World” logged
But I’m using Glitch to submit the exercise.
All I did was add
console.log(“Hello World”)
to the myApp.js file. When I try to run the app in Glitch by typing
node myApp.js
I get this error:
Error: Cannot find module ‘express’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/app/myApp.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)

and when I paste the link in to run the test, it doesn’t pass, I get:
test timed out.
Your project link(s)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic Node and Express - Meet the Node console

Link to the challenge:

Thanks Randell,
When I submitted the link to the Glitch code, instead of the live project, a message appears under the textbox:
“Remember to submit the Live App URL.”
and the test results say:

// running tests
“Hello World” should be in the console
// tests completed
// console output [Error]

Here’s the link to the Glitch code that I used:

You must submit the live project url to the FCC site. I just needed to see the code, which is why I asked you to post a link to the actual project code.

You have a few issues. For some reason, you put node on the first line of the package.json file. You need to delete that.

Once you do that, I recommend adding the following to the end of your package.json file:

,"engines": { "node": "16.x" }

Make sure you put it before the last } in the file. This should allow your project to run on Glitch without errors you would be getting otherwise.

Thanks again, Randell!
The node on the first line was a mistype–I was trying to run the code by typing
node myApp.js in the console, but my cursor was in the code editor and I didn’t notice.

Adding the “engines” field did the trick.

Thanks again for helping out–I really appreciate it!

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