I needed to make a few tweaks to an old Angular project. This project hasn't had a commit for two years and as such my current dev environment is two years ahead. The main issue was with conflicting versions of TypeScript.
ng serve would throw the following error.
ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.9.10 was found instead.
This is easily fixed by installing a compatible version in the project. and passing the
--save-exact parameter into the
npm install command.
npm i email@example.com --save-dev --save-exact
This allows me to run the latest version of TypeScript by default while still allowing older projects to use targetd versions.