  At ambient pressure, bulk 2H-NbS$_2$ displays no charge density wave
instability at odds with the isostructural and isoelectronic compounds
2H-NbSe$_2$, 2H-TaS$_2$ and 2H-TaSe$_2$, and in disagreement with harmonic
calculations. Contradictory experimental results have been reported in
supported single layers, as 1H-NbS$_2$ on Au(111) does not display a charge
density wave, while 1H-NbS$_2$ on 6H-SiC(0001) endures a $3\times 3$
reconstruction. Here, by carrying out quantum anharmonic calculations from
first-principles, we evaluate the temperature dependence of phonon spectra in
NbS$_2$ bulk and single layer as a function of pressure/strain. For bulk
2H-NbS$_2$, we find excellent agreement with inelastic X-ray spectra and
demonstrate the removal of charge ordering due to anharmonicity. In the 2D
limit, we find an enhanced tendency toward charge density wave order.
Freestanding 1H-NbS$_2$ undergoes a $3\times3$ reconstruction, in agreement
with data on 6H-SiC(0001) supported samples. Moreover, as strains smaller than
$0.5\%$ in the lattice parameter are enough to completely remove the $3\times3$
superstructure, deposition of 1H-NbS$_2$ on flexible substrates or a small
charge transfer via field-effect could lead to devices with dynamical switching
on/off of charge order.
