generated/ holds factories, proxies, and interceptors that setup:di:compile writes. pub/static holds the CSS and JavaScript the browser loads. When either tree is half-deleted, owned by the wrong user, or deployed in the wrong mode, Magento includes files that are not there or refuses to publish new ones.

These are deploy failures. They are not fixed by adding a column to a content table or by clearing the browser cache alone.
Warning: include(.../generated/code/...): Failed to open stream
Failed to open stream: No such file or directory (.../registration.php)
Magento\Framework\Exception\FileSystemException: Cannot gather stats
mv: cannot move 'pub/static' to 'pub/static_bak/static': Permission denied
Cannot gather stats means PHP stat() failed for a path Magento expected to exist, often a static file named in the error. Permission denied on mv means the user running deploy cannot rename that directory. The web server user and the deploy user are not the same person.
php bin/magento deploy:mode:show
Developer mode writes static files when the browser asks, and it does not want a full setup:static-content:deploy unless you pass -f. Production mode serves only what that command published. Compiling and deploying while the site is in the wrong mode explains a shop that works for you in a terminal and 404s for customers.
From the Magento root, during a maintenance window:
php bin/magento maintenance:enable
rm -rf generated/code generated/metadata var/cache var/page_cache var/view_preprocessed
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento maintenance:disable
Windows PowerShell does not have rm -rf:
Remove-Item -Recurse -Force generated\code, generated\metadata, var\cache, var\page_cache, var\view_preprocessed
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Put the site in maintenance mode before you delete generated/ on a shop that is serving customers. Do not delete generated/ on a live production box in the middle of traffic. Requests that arrive before compile finishes throw the same include warnings you are trying to cure. Do not delete var/log if you still need the error, and do not delete app/etc/env.php.
registration.php missing under vendor/ is not a generated-code problem. composer install has not finished, or vendor/ was deleted. Restore it from composer.lock before compiling:
composer install --no-dev
--no-dev belongs on production. Locally, omit it if you need dev tools.
Production, from a user who can write pub/static:
php bin/magento setup:static-content:deploy en_US
Add every locale the stores use. A German storefront with only en_US deployed still 404s de_DE files, which then shows up as Cannot gather stats for a path under de_DE.
pub/static is the directory browsers request. generated/code is the directory PHP includes. A 404 for styles.css is the first. A missing factory class is the second. Deploying static files does not create factories, and setup:di:compile does not publish CSS. Run the command that matches the missing path. On Windows, deploy with --strategy=copy. The symlink strategy needs a privilege most local Apache accounts do not have, and a failed symlink looks like an empty theme.
If deploy cannot move pub/static aside:
ls -ld pub pub/static
The owner must be the user running PHP, or that user must be in the group and the directory must be group-writable. Do not chmod 777. On a typical two-user setup, deploy as the same user php-fpm uses, or grant the group write and set the setgid bit on pub/static and var so new files stay in that group.
The chmod calculator shows the same mode as a number and as a command. Do not use 777.
Developer mode: skip the deploy, flush cache, and reload. If you already deployed with -f in developer mode, Magento stops generating files until you remove the deployed sign. Removing pub/static/deployed_version.txt after a bad deploy lets developer mode take over again. Do that only in developer mode.
php bin/magento setup:di:compile exits 0.pub/static/frontend/... returns 200.var/log/exception.log has no new FileSystemException for that CSS path.ls pub/static/frontend shows your theme and locale, not only Magento/blank.memory_limit for that process. That is a separate fault from a missing file.pub/static is a symlink into a release directory the current user cannot rename. Fix the release layout. Do not copy the symlink target over itself.registration.php or theme.xml is missing, so deploy skips it and the admin cannot select it. Restore the theme before deploying again.pub/static files that Linux cannot read after a zip copy, because of a path that was too long. Deploy on the server. Do not upload pub/static from a Windows working copy.Not during traffic. Requests that arrive before compile finishes throw the same missing-file errors.
No. Developer mode writes files on request. Deploy with -f there stops that until the deployed sign is removed.
Often it is the deploy command. A German storefront needs de_DE in the deploy list, not only en_US.