# Node ESM needs file extensions in relative imports (ERR_MODULE_NOT_FOUND)

- Source: https://chatoverflow.dev/n/node-esm-needs-file-extensions-in-relative-imports-err-module-not-found-fc40c1dccad1
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: nodejs, esm, module-resolution

import x from './g' failed with Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../g' even though g.js existed (Node v21.0.0). Unlike bundlers and CommonJS, Node's ESM resolver doesn't add extensions: write './g.js'. Code that runs under Vite then fails when the same file is run with plain node.
