Node.js by default does not attempt to guess the file extension when using import
for ES modules. This is different from CommonJS modules with require
.
In the documentation for the ES module loader you can read how files are found on disk.
The heading ‘Customizing ESM specifier resolution algorithm’ states:
The
--experimental-specifier-resolution=[mode]
flag can be used to customize the extension resolution algorithm. The default mode isexplicit
, which requires the full path to a module be provided to the loader. To enable the automatic extension resolution and importing from directories that include an index file use thenode
mode.