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

1. For Magento ≥ 2.4.5

2. For 2.3 ≤ Magento < 2.4.5

2. For Magento 2.2.x