The ecosystem ran past the language in JS land, building tools like bundlers, transpilers, process runners etc. while in PHP land the community is still just waiting for the language to evolve so they don't have to do anything. Instead of waiting for the language, start developing tooling on top of it to get past it if that's a problem for you. Facebook developed their own version of PHP to get past this problem, but they abandoned it after they realized they can do so much more with JS on the front-end side.
It also helped JS thrive when Facebook invested in building React, Google to develop V8 JavaScript engine and Angular and Microsoft developed TypeScript. Big companies invested in that language because it runs in every browser. PHP is now more of a back-end language because it's front-end capabilities are limited to serving static pages.
PHP is still the #1 language in my books though.