Molecular dynamics simulations are performed to investigate the nucleation and growth of cavities in a hydrated Nafion membrane under mechanical deformation. The simulation model used in this study accurately reproduces the experimental values of the elastic modulus of the membrane as a function of water content. The results obtained from triaxial tensile tests reveal a ductile to brittle transition as the water content increases. The nucleation and growth of the cavities have been quantitatively analyzed in terms of the number and size of cavities, illustrating the ductile to brittle transition uncovered by the stress/strain curves. Further local analyses have been carried out to identify the nucleation sites. The analysis of local plasticity indicates that as the water content increases, the membrane accumulates more plastic deformation in the hydrophilic domain than in the hydrophobic domain during the rupture stage of the tensile tests. These results suggest that the water network significantly impacts the nucleation and expansion of cavities induced by mechanical deformation. Furthermore, the local mechanical properties of the Nafion membrane are evaluated. The results show that the mechanical properties are heterogeneous at the nanoscale and that the cavities nucleate in soft regions of the membrane. A statistical analysis of the local water density of nucleation sites indicates that the polymer-water interfaces are more likely to nucleate cavities. The expansion and coalescence of cavities is facilitated by the high molecular reorganization of the water network, which explains the brittle behavior of membranes with high water content.