There are many blog posts out there that show how you can install packages to your SPFx project. Many of those projects tell you that you have to install exactly this specific version.
To give you an example upgrading your rush stack compiler in an existing project you can use the following line of code.