Although Professor Moriarty appears frequently in adaptations of Conan Doyles' work, he didn't
directly feature in any of the Sherlock Holmes novels until 'The Adventure of the Final Problem' (where the Reichenbach Falls incident occurs).
Prior to that he'd only been mentioned in Holmes's reminiscences. He then subsequently appeared in only one other novel, 'The Valley of Fear', which although it was written later than 'The Adventure of the Final Problem', was set before it.
Source:
https://en.wikipedia.org/wiki/Professor_Moriarty