In-situ Raman experiments together with transport measurements have been carried out on carbon nanotubes as a function of gate voltage. In metallic tubes, a large increase in the Raman frequency of the $G^-$ band, accompanied by a substantial decrease of its line-width, is observed with electron or hole doping. In addition, we see an increase in Raman frequency of the $G^+$ band in semiconducting tubes. These results are quantitatively explained using ab-initio calculations that take into account effects beyond the adiabatic approximation. Our results imply that Raman spectroscopy can be used as an accurate measure of the doping of both metallic and semiconducting nanotubes.