I didn’t write this script, but it works as an editor extension, not as a component! You need to have it saved to a FOLDER called “Editor” - the terrain object can be called anything.
When the script compiles Unity should then add a “Terrain → Export to Obj.” option to the menu bar (up top, with “File, Edit, View”, etc.). Click that and you should be good to go.