Getting Internal Server Error on dynamically generated sitemap

I am use dynamic sitemap generation technique of nextjs(XML Sitemaps - Crawling and Indexing | Learn Next.js). Once the site is deployed on netlify, when I visit to my website’s sitemap page, I am getting Internal Server Error.

My Netlify Site:
My Sitemap Page:

Hi @Ashwith ,

As far as I can tell this is a typical error for folks trying to use next.js 13.5 on our service as you are, shown here in your build logs:

I saw the error that made me realize that in your function logs here: Netlify App (the cannot find module error is a problem that can occur with newer next.js).

Please try v 13.4 and let me know if things work better! (you’ll need to set an explicit version in package.json/yarn.lock and confirm that we saw it my looking at your deploy logs to see the version used).

Thanks mate, its working.