If it works fine with the 200-500mm, then the problem is either:
with the 18-140mm lens. Or,
with the combination of the interaction between your particular camera and your 18-140mm lens.
The way to absolutely diagnose it is to try your 18-140mm on multiple different camera bodies, and to try multiple other lenses on your D5300 body. If the problem occurs when you lens is mounted to different bodies, then the problem is with your lens. And conversely, if the problem occurs with other lenses mounted on your camera, then the camera body is the likely suspect. Unfortunately, most of us don't have several camera bodies and lenses we can interchange to do this diagnosis. So you'll probably have to have them serviced.
In your description, you said that even if the error doesn't appear, with your 18-140mm lens the images appear overexposed. This sounds like your lens has a sticky, bent, or otherwise suffers from high friction somewhere in the aperture or aperture linkage system, as though the aperture does return to its spring-loaded stopped-down position (or at least, its setting less than fully open). That's why images are still overexposed.
Unless you're familiar and comfortable with lens repair, there's not much you do, other than have the lens serviced or repaired.