Measurements of prompt ψ(2S) meson production cross sections in proton–lead (pPb) and proton–proton (pp) collisions at a nucleon–nucleon center-of-mass energy of s NN =5.02TeV are reported. The results are based on pPb and pp data collected by the CMS experiment at the LHC, corresponding to integrated luminosities of 34.6 nb −1 and 28.0 pb −1 , respectively. The nuclear modification factor R pPb is measured for prompt ψ(2S) in the transverse momentum range 4<p T <30GeV/c and the center-of-mass rapidity range −2.4<y CM <1.93. The results on ψ(2S) R pPb are compared to the corresponding modification factor for prompt J/ψ mesons. The results point to different nuclear effects at play in the production of the excited charmonium state compared to the ground state, in the region of backward rapidity and for p T <10GeV/c.