Skip to content

loadNodeModules() should be more clear about what went wrong #143

Closed

Description

@krainboltgreene

I had an error loading a library, but all it told me is that it couldn't resolve the module. That's fine, but the real issue is that the package's main file didn't exist.

Here's some payload information:

{ x: 'snabbdom-view',
  start: '/Users/krainboltgreene/Code/krainboltgreene/deushack/source/client/cycle',
  dirs: [] }

We can definitely make this better. We can say all the directories we looked in, what exact file we;'re looking for (in this case main) and then do some reading to show the user that it's the package;'s fault.

Activity

  1. ljharb commented on Nov 16, 2017

    @ljharb
    Member

    What does require.resolve tell you in that scenario?

    Why would the issue here just be "missing main"? Couldn't also Users/krainboltgreene/Code/krainboltgreene/deushack/source/client/cycle.js or Users/krainboltgreene/Code/krainboltgreene/deushack/source/client/cycle/index.js also be missing?

  2. krainboltgreene commented on Nov 16, 2017

    @krainboltgreene
    Author

    In this case the package had a "main": "transpiled/source/index.js" which literally didn't exist.

  3. krainboltgreene commented on Nov 16, 2017

    @krainboltgreene
    Author

    Three parts for improvement:

    1. Tell the user where we looked.
    2. Tell the user what we looked for.
    3. Either tell the user why we failed OR send them to an FAQ.

    I would love to work on this as a PR.

  4. ljharb commented on Nov 16, 2017

    @ljharb
    Member

    I'm hesitant to add complexity, even in error paths - but if you're willing, taking a look at it via a PR would be helpful.

  5. calvinqc commented on Oct 27, 2020

    @calvinqc

    @ljharb Hi Jordan, this issue sounds very interesting even though it's been here for a long time. I'm wondering whether it's still opened and still recommended to work on now?

  6. ljharb commented on Oct 27, 2020

    @ljharb
    Member

    @calvinqc yes, that'd be great! Be mindful though, that changing error message text has been semver-major in the past, so I'm highly likely to only accept the PR into v2 (the default branch) and not be able to backport it into v1 (the 1.x branch).

  7. krainboltgreene commented on Oct 29, 2020

    @krainboltgreene
    Author

    Is it still breaking if you get a generic semi-related error before and now you get a specific error?

  8. ljharb commented on Oct 29, 2020

    @ljharb
    Member

    @krainboltgreene yes, potentially - there are tools that rely on the exact string and type of an error that resolve throws in specific situations. I've broken angular-cli and ember-cli before by changing an error message, and am not anxious to repeat it.

  9. krainboltgreene commented on Nov 2, 2020

    @krainboltgreene
    Author

    As the maintainer of a big project i feel that.

  10. added a commit that references this issue on Dec 23, 2020
    4bece07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions