Given a nondegenerate minimal hypersurface $\Sigma$ in a Riemannian
manifold, we prove that, for all $\varepsilon$ small enough there exists
$u_\varepsilon$, a critical point of the Allen-Cahn energy $E_\e (u) =
\varepsilon^2 \, \int |\nabla u|^2 + \int (1-u^2)^2$, whose nodal set
converges to $\Sigma$ as $\varepsilon$ tends to $0$. Moreover, if $\Sigma$
is a volume nondegenerate constant mean curvature hypersurface, then the
same conclusion holds with the function $u_\varepsilon$ being a critical
point of $E_\e$ under some volume constraint.