How to find which R package version should be used for shiny server deployment?

I just started to use rsconnect in my company, and tried to deploy a shiny app from my windows machine. The server comes with R 4.1.0, and one of the packages requires to install terra.

I have tried multiple R package repos from Rstudio dev-cran with different dates to install terra, and tried version 1.2-10, 1.3-4, ... all the way to the latest version.

However, none of them was able to be uploaded, or installed during deployment.
For the versions before 1.4, the error was

Uploading bundle for application: 335...Error: node stack overflow
Execution halted

while for versions above 1.4, parts of the error were

The requested URL returned error: 407
RStudio Connect cannot download a package because the R package repository (for example, CRAN or RStudio Package Manager) cannot be accessed.

Also, for some other packages, I installed them from rsconnect R package manager. However, once I started to deploy, it showed that the connect to the repo that I used to install the package cannot be accessed.

Any suggestions for the next step?