A multi-dimensional analysis of prompt charmonia in pp and pPb collisions at root s(NN) = 5.02 TeV with the CMS detector is presented. The pPb differential cross-sections of prompt J/psi are shown in a wide kinematic region, for transverse momentum p(T) spanning from 2 to 30 GeV/c and a rapidity interval between -2.4 to 1.93 in the center of mass of the collision. The final results on prompt psi/(2S) meson production cross section in pp and pPb collisions at 5.02 TeV are also reported as a function of p(T) and rapidity, for p(T) from 4 to 30 GeV/c. The nuclear modification factor is found to be smaller than that of prompt J/psi in all measured bins, especially at low p(T) and at backward rapidity. Such a different behaviour between the ground and excited states cannot be reproduced considering nPDF effects alone.