I ran into this error in development because of a broken symbolic link.
I had created a file in a module's view/frontend/web
directory that in developer
mode was deployed to the pub/static
directory using a symbolic link that pointed to the module's directory where the original file is stored.
At some point in development I removed the file from my module, but the symbolic link still existed in pub/static
pointing to a file that no longer existed. I expect this would also be the case if I had renamed one of the files.
If a site is in production
mode and has had bin/magento setup:static-content:deploy
run, that actually copies the files to the pub/static
directory instead of creating symbolic links.
In order to find this broken symbolic link I ran a command from the shell
find -L . -type l
Removing the broken symbolic link resolved the problem (for example using find -L . -type l -exec rm {} \;
).