Render with read-only folder permissions

Trying to render() a markdown file from folder without write permissions. So I use the output_dir parameter to pass a (temp) folder with write permission, however .md files are still being created in the folder where the .rmd file is located. But ultimately the end user does not have the permissions to create files there.

render('MyFile.Rmd', intermediates_dir = tempdir())
--> I get "Error: node stack overflow"
render('MyFile.Rmd', knit_root_dir = tempdir())
--> I get an error while sourcing a file in the markdown

When I suggested knit_root_dir and intermediates_dir arguments of render in my previous post (now deleted), I actually meant to specifically supply the path to the directory where the user have write access like this:

rmarkdown::render(input = "<absolute_or_replative_path_of_the_Rmd_file>",
                  output_dir = "<absolute_or_replative_path_of_the_directory_where_final_results_are_desired>",
                  knit_root_dir = "<absolute_or_replative_path_of_the_directory_what_will_be_working_directory_during_rendering>")

Thanks for your help Yarnabrina.
I was able to make it work by specifying output_dir, intermediates_dir and I also needed to specify output_file.
However it only worked with setting the markdown option self_contained to FALSE. When set to true I get this error:
cannot create file '...\JapanLoader\Output\JapanLoader_files/dt-core-1.10.16/js/jquery.dataTables.min.js', reason 'No such file or directory'


Also this error goes away when I run a second time. (I always need to run twice)...