Errors
ERR_MODULE_NOT_FOUND
An ESM import cannot resolve the requested module. Confirm the specifier and explicit file extension; avoid automatically installing a package based on an error string. Tested on Node.js 22.16.0. Example output (one line per entry): ["ERR_MODULE_NOT_FOUND", "function"].
Formal Syntax & Structure
nodejs syntaxnodejs
error.code === "ERR_MODULE_NOT_FOUND"Return Value
Error
Observed error classification; successful correction has its own return value.
Working Example
Example Snippetnodejs
try { await import('./bytemind-nonexistent.mjs');}catch (e) { console.log(e.code);}console.log(typeof (await import('node:path')).join);