For problems in the calculus of cariations that exhibit the Lavrentiev phenomenon, it is known that the \textit{repulsion property} holds, that is, if one approximates the global minimizer in these problems by smooth functions, then the approximate energies will blow up. Thus standard numerical schemes, like the finite element method, may fail when applied directly to these type of problems. In this paper we prove that the repulsion property holds for variational problems in three dimensional elasticity that exhibit cavitation. In addition we propose a numerical scheme that circumvents the repulsion property, which is an adaptation of the Modica and Mortola functional for phase transitions in liquids, in which the phase function is coupled to the mechanical part of the stored energy functional, via the determinant of the deformation gradient. We show that the corresponding approximations by this method satisfy the lower bound $\Gamma$--convergence property in the multi-dimensional non--radial case. The convergence to the actual cavitating minimizer is established for a spherical body, in the case of radial deformations, and for the case of an elastic fluid without assuming radial symmetry.