I’m working through freeCodeCamp’s back-end timestamp microservice project in a GitHub Codespaces workspace running Node.js v24.18.0, and the server just will not start no matter what I try. The project’s package.json has “type”: “module”, so my first attempt using require() failed with “require is not defined in ES module scope” — I switched to import syntax instead, which then failed with “Cannot find package ‘dotenv’” because it wasn’t actually installed, so I dropped that import. After that
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.4 Safari/605.1.15
Challenge Information:
Build a Timestamp Microservice - Build a Timestamp Microservice
You’re actually most of the way there, you just need to make the file consistently ESM. Since package.json has “type”: “module”, stick with import throughout and don’t mix in require. You don’t need dotenv at all for this project, so dropping it was correct, just remove any leftover import for it too. The usual starter needs “import express from ‘express’” and then run “npm install” first so express is actually present, that missing-package error was the same class of problem as dotenv. After that, “node index.js” or “npm start” should boot it. What error are you getting now, right after the dotenv one? Paste the exact message and I’ll pin it down.