If I were you, I'd look for a sub-field that's interesting, something where you enjoy doing the work and learning the material itself. And then wait for the rest of the world to come around. When you look at people who are actually acknowledged as experts, it's usually because they got started on something before it was cool, and then had built up years of expertise when the world decided that this was suddenly the hot new thing. Note that there's plenty of risk in this: there's no guarantee that the world will actually come around, and you might end up working on something that the rest of the world thinks is a niche hobby. But at least you'll be working on something you enjoy, which is sorta the point of life after all.
It may be easier for a generalist to get a job (any job) because there will always be somebody who needs to get X done with Y technology and somebody who can learn Y technology quickly and get X done is in demand.
On some level you are not going to be all that productive doing that since you will spend your time learning how to get the length of of a String with technology Y and then having to learn it all over against with technology Z.
At that rate, however, you will be a "junior developer" when you are 45.
On the other hand if you develop some specialized skill it may well be that this skill is not in demand or that the jobs involving this skill may not be well paying, etc. (i.e. many of the best paying jobs give you hazard pay for working with toxic people, toxic code, toxic tooling, etc. -- even if you are objectively more productive taking a "path less followed" you are bucking the dominant paradigm)
There is "no silver bullet" for careers in software development.
Read the best and as many relevant books you can afford about current and next subjects you are working on. Keep reading. Don't stop reading.