Closed
Description
If there is an "exports" field in the package.json file of a module, the "main" field becomes ignored by the resolver and if one tries to import something from 'package'
where there is no '.'
export, it throws an error:
Cannot resolve package exports target 'undefined' matched for '.' in /home/mzasso/test/bug-exports/node_modules/my-module/package.json, imported from /home/mzasso/test/bug-exports/test.mjs
Is this the expected behavior? If so, the documentation is not clear about that.
By the way, the exports resolver could probably be improved, saying that there was no matching key instead of trying to use "undefined"
as the value.
Repro: https://github.com/targos/bug-esm-exports
@nodejs/modules-active-members