Reproduction
- Start Build a Prime Number Checker Module.
- Create
index.js with:
function isPrime(n) {
if (n < 2) return false;
if (n < 4) return true;
if (n % 2 === 0 || n % 3 === 0) return false;
for (let i = 5; i * i <= n; i += 6) {
if (n % i === 0 || n % (i + 2) === 0) return false;
}
return true;
}
module.exports = isPrime;
- Add a valid CommonJS
package.json.
- Click Run Tests.
Actual behavior
The page reports:
Error 4XX - 5XX
Client has disconnected from local server
The course test worker fails on the export test with DataCloneError. The test imports the CommonJS module as an ES module namespace. With module.exports = isPrime, the namespace does not expose isPrime directly, so the assertion fails. Its error object contains a function and cannot be sent through parentPort.postMessage.
The later two tests then fail because their fallback assigns the module namespace object to isPrime and attempts to call it.
Expected behavior
The runner should remain connected and show an ordinary failed test with an actionable export message.
The intended submission shape passes all six tests:
module.exports = { isPrime };
Verified against
back-end-development-and-apis current main
@freecodecamp/freecodecamp-os 3.5.4
The earlier Build a Case Converter course teaches the object export form, but this project's text only says to export isPrime using module.exports and calls it a named export. An explicit expected export snippet would avoid directing learners toward the crashing path.
Reproduction
index.jswith:package.json.Actual behavior
The page reports:
The course test worker fails on the export test with
DataCloneError. The test imports the CommonJS module as an ES module namespace. Withmodule.exports = isPrime, the namespace does not exposeisPrimedirectly, so the assertion fails. Its error object contains a function and cannot be sent throughparentPort.postMessage.The later two tests then fail because their fallback assigns the module namespace object to
isPrimeand attempts to call it.Expected behavior
The runner should remain connected and show an ordinary failed test with an actionable export message.
The intended submission shape passes all six tests:
Verified against
back-end-development-and-apiscurrentmain@freecodecamp/freecodecamp-os3.5.4The earlier
Build a Case Convertercourse teaches the object export form, but this project's text only says to exportisPrimeusingmodule.exportsand calls it a named export. An explicit expected export snippet would avoid directing learners toward the crashing path.