Error in installing packages 'knitr', 'mdsr', 'rmarkdown'

I am trying to install following packages: rmarkdown, knitr, mdsr.
But when I try to install them, same error occurs like below

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'xfun' 0.43 is being loaded, but >= 0.44 is required
Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'knitr'
removing 'C:/Users/LG-PC/AppData/Local/R/new-library/knitr'
Warning in install.packages :
installation of package ‘knitr’ had non-zero exit status

How should I handle it? I am stuck

You need to update that package first.

You can also try pak, it will automatically update all required packages. Install it like this:

install.packages("pak", repos = sprintf(
  "https://r-lib.github.io/p/pak/stable/%s/%s/%s",
  .Platform$pkgType,
  R.Version()$os,
  R.Version()$arch
))

(Cf. All about installing pak. — Installing pak • pak) and then run:

pak::pkg_install(c("rmarkdown",  "knitr", "mdsr"))

Thanks a lot for a great help!