Skip to content

Better "module not found" message #401

Closed

Description

@gaearon

This is what I see when I forget to install some npm dependencies:

screen shot 2016-08-08 at 16 34 37

wat

This is overwhelming and unnecessary.
We should have simple messages, like:

These dependencies were not found in node_modules:

  * redux
  * react-redux

Did you forget to run npm install --save for them?

I’m not sure what to do with local file missing errors (i.e. when you import a non-existing file in src). We should probably group them separately but also in a less intimidating way.

I don’t personally plan to work on this so any help is welcome!

Activity

  1. gaearon commented on Aug 8, 2016

    @gaearon
    ContributorAuthor

    If you plan to work on this please leave a comment. We don’t want many people to work on the same thing at the same time.

    A good place to start looking at would be scripts/start.js. We already handle Webpack errors in an unorthodox way so we may want to keep refining that.

    cc @geowarin who also was looking into improvements to webpack output in geowarin/tarec#16.

  2. rogeliog commented on Aug 8, 2016

    @rogeliog
    Contributor

    @gaearon I would love to work on this one 😄

  3. geowarin commented on Aug 8, 2016

    @geowarin
    Contributor

    Hi @gaearon.

    If you change this line to var json = stats.toJson({}, true);, you'll get a much shorter error output.
    It is what webpack normally displays on errors (ie, when you don't parse the errors yourself) and it doesn't include the details field.
    See here.

    This is a short term measure before somebody actually dives into webpack internals to do exactly what you suggested.
    (I'm working on geowarin/tarec#16 and as promised I will contribute back when it's ready but if somebody wants to tackle it in the meantine, it would be interesting)

  4. added a commit that references this issue on Aug 8, 2016
  5. jnsdls commented on Aug 8, 2016

    @jnsdls

    this would be a great change not just for this specific project but in general (at least as an option)

  6. rogeliog commented on Aug 9, 2016

    @rogeliog
    Contributor

    Seems that @geowarin already has a PR 👍, he also has more domain knowledge than me!

  7. geowarin commented on Aug 10, 2016

    @geowarin
    Contributor

    I created the friendly-errors-webpack-plugin.

    It still needs more work (see the TODO in the README) but I'd love to see your feedback/ PR. 😄
    ETA: Friday night

  8. rogeliog commented on Aug 11, 2016

    @rogeliog
    Contributor

    @geowarin Awesome, given that you created friendly-errors-webpack-plugin I thought that it would make more sense me to PR that repo instead of this one. geowarin/friendly-errors-webpack-plugin#1

  9. rogeliog commented on Aug 18, 2016

    @rogeliog
    Contributor

    @geowarin is there an update on this? I'm more than happy to pick it up or help out with anything :)

  10. added a commit that references this issue on Aug 22, 2016
  11. fson commented on Aug 30, 2016

    @fson
    Contributor

    What if instead of

    Did you forget to run npm install --save for them?
    

    missing packages would bring out a prompt to install them for you?

    Would you like to install the missing packages? [Y/n]
    
  12. geowarin commented on Aug 31, 2016

    @geowarin
    Contributor

    Update: there is a PR implementing this.

    @fson It would be great to provide autofixes! The only part I'm not sure about is how to allow simple interactions with the console since it is cleared every now and then.

  13. gaearon commented on Aug 31, 2016

    @gaearon
    ContributorAuthor

    I’m a bit worried about autofixes because it’s easier to miss typos and install something you didn’t want. I’d like installation act to be explicit.

  14. added a commit that references this issue on Sep 7, 2016
  15. mareksuscak commented on Sep 11, 2016

    @mareksuscak
    Contributor

    @gaearon As per Heroku's Node.js best practices we could mitigate the issue by providing .npmrc in the project root folder for newly created projects with essential defaults. We've been using that technique for quite a while now and it's certainly lowered the number of those "forgotten to --save the dependency" issues. If interested I could work on that part.

    This is what we use:

    save=true
    save-exact=true
    
  16. fson commented on Sep 11, 2016

    @fson
    Contributor

    @mareksuscak Thanks for the tip, didn't know about this setting before. However, I think it could increase the confusion in some cases, because we would basically be creating a hidden file that makes npm behave differently from the default. People might not notice it or understand what it does, only npm would seem to behave differently from time to time. That's why I think a simple message showing how to use npm install --save, as suggested originally, would be a better option.

    This project also aims to avoid adding configuration and flags as much as possible, so generating a .npmrc file would not fit well in this philosophy.

  17. added a commit that references this issue on Oct 25, 2016
  18. gaearon commented on Mar 7, 2017

    @gaearon
    ContributorAuthor

    I think this was fixed.

  19. added a commit that references this issue on Dec 6, 2018
  20. locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions