I assume you are referring to UVB light.
UVB light is used by many vertebrates to photosynthesise vitamin D (in an inactive form) in the skin which is then stored in the liver until needed.
Vitamin D is essential to ALL vertebrates as it enables calcium to be taken up from the gut and to be utilised in the body to build hard bones & teeth, enable heart functioning, enable transmission of nerve impulses and skeletal muscle contraction, the release of enzymes and hormones, and more... We do tend to focus just on the building of bones.
AS has been mentioned, those reptiles that eat whole vertebrates as a significant part of their natural diet are capable of accessing and making use of the stored inactive vitamin D in the liver of their prey. They therefore have no need for photosynthesising their own. Medium to large monitors are an excellent example.
While nocturnal reptiles still need vitamin D it would seem on the surface of things that they do not get it via exposure to UVB as they are not active during daylight hours.
With a number gecko species that have been investigated, it seems their skin is remarkably transparent to UVB. The suggestion is that even a small amount of UVB getting through the bark under which they shelter, enables them to photosynthesis vitamin D. Most species of geckos in captivity are given vitamin supplements, including vitamin D. Without those, they may not fare so well... I do not know for sure.
I am aware that quite a few nocturnal tree frog species, kept in conditions of total lack of UVB exposure, were found to be vitamin D deficient. It is thought that even a slight amount of UVB absorbed while hidden in nature amongst foliage during the day, is essential for their well being.
Dragons, irrespective of diet, are extremely dependent on UVB exposure to remain healthy. Skinks, for some reason, are far less dependent on UVB exposure. Young, growing skinks do require it while adults seem to able to get by with very little or zero exposure. We don’t know why.
Nocturnal lizards may take in UVB whilst in their daytime retreats. If this is the case, the amount of UVB required is minimal – a bit like the tree frogs. Again, I do not know for certain.
There are insectivorous monitors that seem not to need UVB in captivity, and that defies what we understand to date. So there is still much to be discovered.
As a generalisation, those lizards that commonly eat whole vertebrates can go without, dragons need high exposure throughout their life, skinks need most when they are young to minimal when older, nocturnal species should be provided with vitamin D as a supplement or provided with a 2% UVB output light in their enclosure.
Regretfully the foregoing still leaves a lot of unanswered questions, the answers to which I would dearly like to know as well.
Blue