Interestingly, I found an article that states a 2021 study of this very problem concluded that "a nuke detonated next to an asteroid 100 meters (328 feet) wide, at least two months before impact, could
blast 99.9% of the asteroid’s mass out of Earth’s way." While there would be no "fireball" in space like we would see on earth, the heat generated from the nuclear reaction would still vaporize a large part of a small asteroid. At the very least the nuke would create enough thrust to move the rock off it's path.
Obviously, the sooner we take out the asteroid, or the farther away from earth, the safer it would be for our planet. The question is, how far away can we intercept a space rock traveling at 38,000 MPH?