We want to investigate whether we can use Lyalpha emission to obtain information on the environment properties and whether Lyalpha emitters show different characteristics as a function of their environment. We estimated local densities in the VANDELS Chandra Deep Field-South (CDFS) and UKIDSS Ultra Deep Survey (UDS) fields, by using a three-dimensional algorithm which works in the RA-dec-redshift space. We selected a sample of 131 Lyalpha-emitting galaxies (EW(Lyalpha)>0 A), unbiased with respect to environmental density, to study their location with respect to the over- or under-dense environment. We identify 13 (proto)cluster candidates in the CDFS and nine in the UDS at 2<z<4, based on photometric and spectroscopic redshifts from VANDELS and from all the available literature. No significant difference is observed in the rest-frame U-V color between field and galaxies located within the identified overdensities. We find that VANDELS Lyalpha emitters (LAEVs) lie preferentially outside of overdense regions as the majority of the galaxies with spectroscopic redshifts from VANDELS. The LAEVs in overdense regions tend to have low Lyalpha equivalent widths and low specific SFRs, and they also tend to be more massive than the LAEVs in the field. Their stacked Lyalpha profile shows a dominant red peak and a hint of a blue peak. Our results show that LAEVs are likely to be influenced by the environment and favour a scenario with outflows of low expansion velocities and high HI column densities for galaxies in overdense regions. An outflow with low expansion velocity could be related to the way galaxies are forming stars in overdense regions; the high HI column density can be a consequence of the gravitational potential of the overdensity. Therefore, Lyalpha-emitting galaxies can provide useful insights on the environment in which they reside.