Corrupt or missing node_modules can sometimes lead to this issue. Deleting the node_modules folder and reinstalling dependencies often fixes the problem.
- Delete node_modules and package-lock.json:
rm -rf node_modules
rm package-lock.json
-
Reinstall all dependencies:
npm install -
Run the Angular project:
ng serve
This approach ensures that all dependencies are reinstalled cleanly and that TypeScript is correctly added to your node_modules.