The energy equalities of compressible Navier-Stokes equations with general pressure law and degenerate viscosities are studied. By using a unified approach, we give sufficient conditions on the regularity of weak solutions for these equalities to hold. The method of proof is suitable for the case of periodic as well as homogeneous Dirichlet boundary conditions. In particular, by a careful analysis using the homogeneous Dirichlet boundary condition, no boundary layer assumptions are required when dealing with bounded domains with boundary.