Restarting your server may not work always. I have got this error when I imported MatFormFieldModule.
In app.module.ts, I have imported MatFormField instead of MatFormFieldModule which lead to this error.
Now change it and restart the server, Hope this answer helps you.