Update MiKTeX packages
Update MiKTeX packages to avoid issues with compiling documents. This is even true for a fresh MiKTeX install.
- Start → MiKTeX Console → Updates → Check for updates
- if updates available, click Update now
Anytime you get an unexpected error, try updating MiKTeX packages.