coding-horror/basic-computer-games · warning · Error

Game "${folder}" is missing a HTML or node.js file in the fo

Error message

Game "${folder}" is missing a HTML or node.js file in the folder "${folder}/${JAVASCRIPT_FOLDER}"

What it means

Thrown by findJSFilesInFolder() when a game folder DOES have a 'javascript' subfolder, but after filtering for .html and .mjs files and removing IGNORE_FILES entries, zero usable files remain. Like error 1 it is caught by main()'s try/catch (build-index.js:134-139) and reported as a warning, with the game dropped from the generated index.

Source

Thrown at 00_Utilities/build-index.js:108

	// filter folders that do not include a subfolder called "javascript"
	const hasJavascript = fs.existsSync(`${folder}/${JAVASCRIPT_FOLDER}`);
	if (!hasJavascript) {
		throw new Error(`Game "${folder}" is missing a javascript folder`);
	}

	// get all files in the javascript folder
	const files = fs.readdirSync(`${folder}/${JAVASCRIPT_FOLDER}`);

	// filter files only allow .html files
	const htmlFiles = files.filter(file => file.endsWith('.html'));
	const mjsFiles = files.filter(file => file.endsWith('.mjs'));
	const entries = [
		...htmlFiles,
		...mjsFiles
	].filter(file => !IGNORE_FILES.includes(file));

	if (entries.length == 0) {
		throw new Error(`Game "${folder}" is missing a HTML or node.js file in the folder "${folder}/${JAVASCRIPT_FOLDER}"`);
	}

	return entries.map(file => path.join(folder, JAVASCRIPT_FOLDER, file));
}

function main() {
	// Get the list of all folders in the current director
	let folders = fs.readdirSync(process.cwd());

	// filter files only allow folders
	folders = folders.filter(folder => fs.statSync(folder).isDirectory());

	// filter out the folders that start with a dot or 00_
	folders = folders.filter(folder => {
		return !IGNORE_FOLDERS_START_WITH.some(ignore => folder.startsWith(ignore));
	});

	// sort the folders alphabetically (by number)

View on GitHub (pinned to 5301155192)

Solutions

  1. Add a runnable .html or .mjs entry-point file to the game's javascript/ folder.
  2. If the only files present are wrongly blacklisted, remove the relevant name from IGNORE_FILES at build-index.js:17-20.
  3. If the game genuinely has no web port, ignore the warning or add the folder to IGNORE_FOLDERS_START_WITH.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check a game's javascript folder for usable files
function hasUsableFiles(folder) {
  const fs = require('fs');
  const files = fs.existsSync(`${folder}/javascript`) ? fs.readdirSync(`${folder}/javascript`) : [];
  return files.some(f => (f.endsWith('.html') || f.endsWith('.mjs')) && !IGNORE_FILES.includes(f));
}

Try / catch

// Same catch as error 1 (build-index.js:134-139) handles this throw:
try { files = findJSFilesInFolder(folder); }
catch (error) { console.warn(`...`); return null; }

Prevention

When it happens

Trigger: A game's javascript/ folder contains only non-.html/.mjs files (e.g. only .js, .css, .json), or contains only files listed in IGNORE_FILES ('cli.mjs','superstartrek.mjs'), or is completely empty.

Common situations: The folder holds only helper modules (.js) with no runnable .html entry point; every .mjs in the folder happens to be in IGNORE_FILES; build artifacts were committed but the real .html was not.

Related errors


AI-assisted analysis of coding-horror/basic-computer-games@5301155192 (2026-08-13). Data as JSON: /api/errors/db042c66b73f193d. Report an issue: GitHub.