Function works fine in dev but 'Runtime.ImportModuleError - Error: Cannot find module '@sendgrid/mail'

Adding

[functions]
   external_node_modules = ["@sendgrid/mail"]

Seemed to work.

Can you explain why?
I don’t have this on another machine using the same repo, which runs netlify build without any issue.
cf: Netlify build works on one machine, build fails on the other