Developers less familiar with modern JavaScript likely have trouble understanding why an error message like this comes up after running yarn start:

Would create-react-app benefit from adding a check on yarn start that ensures the latest dependencies are already installed?
I think we should improve this message. We already parse it so might as well add some friendly instructions.
I don鈥檛 think automatic installation is something we鈥檇 want to pursue. There are many details that are easy to get wrong: npm and yarn can break each other鈥檚 trees (and we don鈥檛 know which one the user used last), the dependency may still be missing in package.json and we might install a wrong version, there might be a typo so installing won鈥檛 help, etc.
With that in mind would you like to work on brainstorming how to improve this message for the most common cases?
My _guess_ for the most common cases are:
yarn install (or npm install) after the dependencies changed (e.g. after a git pull)import Foo, saved, and forgot to run yarn installWe could show TLDR instructions for fixing all of these cases (which would link to a longer article potentially with commenting allowed), and then use some heuristics for ordering which one appears at the top.
It's probably much more complicated than this, but example heuristics:
yarn.lock was modified sooner than node_modules was modified, and the import is to a file doesn't exist in the project, we would suggest the developer run yarn install at the top of the instructionsnode_modules folder and the node_modules folder was last updated before yarn.lock?[0]:
[3] pry(main)> Order.new.profil
NoMethodError: undefined method `profil' for #<Order:0x007fbc2b152f68>
Did you mean? profile
profile=
profile?
Personally, I'd go with something simpler like looking up the missing module in package.json and maybe in node_modules as well; if it is not found print something like module "foo" was not found. Please install it with npm (npm install --save foo) or yarn (yarn add foo).
If you ask me I would stick to option to show message but not install dependencies.
Side-effects are always tricky to maintain.
Another thing is this could be a local file and not a module. If you use basePath in a jsconfig (or ts) to make importing from other files in your app easier, then trying to install something wont help. In this case its most likely a typo
Most helpful comment
I think we should improve this message. We already parse it so might as well add some friendly instructions.
I don鈥檛 think automatic installation is something we鈥檇 want to pursue. There are many details that are easy to get wrong: npm and yarn can break each other鈥檚 trees (and we don鈥檛 know which one the user used last), the dependency may still be missing in package.json and we might install a wrong version, there might be a typo so installing won鈥檛 help, etc.
With that in mind would you like to work on brainstorming how to improve this message for the most common cases?