I use “jetifier” for this on building my node_modules. To rebuild I remove the node_modules directory then run “npm i” to reinstall and jetifer will run after its complete and fixes those references.
Then in my package.json:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"lint": "ng lint",
"postinstall": "jetifier"
}