How to fix the «Invalid template file» / «require_js.phtml» failure for Magento 2.2.x in Windows?

How to fix the «Invalid template file» / «require_js.phtml» failure for Magento ≥ 2.4.5 in Windows?