ENOfficial
Jundub told of his hearing the Prophet (ﷺ) say, “Those who preceded you used to take the graves of their prophets and righteous men as mosques, but you must not take graves as mosques; I forbid you to do that.” Muslim transmitted it.
Source: sunnah.com
Other translations
Arabic
وَعَن جُنْدُب قَالَ: سَمِعْتُ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ يَقُولُ: «أَلَا وَإِنَّ مَنْ كَانَ قَبْلَكُمْ كَانُوا يَتَّخِذُونَ قُبُورَ أَنْبِيَائِهِمْ وَصَالِحِيهِمْ مَسَاجِدَ أَلَا فَلَا تَتَّخِذُوا الْقُبُورَ مَسَاجِدَ إِنِّي أَنْهَاكُمْ عَنْ ذَلِكَ» . رَوَاهُ مُسلم
sunnah.com