Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better not found errors for ESM #30603

Closed
guybedford opened this issue Nov 22, 2019 · 5 comments
Closed

Better not found errors for ESM #30603

guybedford opened this issue Nov 22, 2019 · 5 comments
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. feature request Issues that request new features to be added to Node.js. good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.

Comments

@guybedford
Copy link
Contributor

When not using a file extension in ESM - eg import pkg from './path' we currently just throw a straightforward not found error. As proposed by @MylesBorins in nodejs/modules#443 it would be useful to enhance this error message.

Ideally the error message should run the CJS resolver and say "the CJS resolver would have resolved this module to ...". We actually previously had this code path implemented by @bmeck but it seems to have got lost along the way. See the early implementation at https://github.com/nodejs/node/pull/14369/files#diff-3e94629c67625a2547d1507d0a547211R20.

Sorry @bmeck I think I might have dropped this and forgot to add it back when refactoring error codes to be standard. That was bad.

@guybedford guybedford added the esm Issues and PRs related to the ECMAScript Modules implementation. label Nov 22, 2019
@iwnow
Copy link

iwnow commented Nov 24, 2019

I have the same issue with ESM "type": "module": extensionless files are not resolved

@guybedford guybedford added good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels Nov 25, 2019
@juanarbol
Copy link
Member

I think I could help with this

@juanarbol
Copy link
Member

juanarbol commented Nov 28, 2019

I quite lost with this issue, which Module method should I use? I was trying with Module._resolveFilename, but I'm having troubles with parent, parent url is file://whatever and not an instance of Module

@juanarbol
Copy link
Member

I need some help D:

PR #30699

@guybedford guybedford added the feature request Issues that request new features to be added to Node.js. label Mar 12, 2020
@guybedford
Copy link
Contributor Author

Resolved in #31906 thanks for @dnlup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. feature request Issues that request new features to be added to Node.js. good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants