Context. The rotation period of stars is an important parameter along with
mass, radius, effective temperature. It is an essential parameter for any
radial velocity monitoring, as stellar activity can mimic the presence of a
planet at the stellar rotation period. Several methods exist to measure it,
including long sequences of photometric measurements or temporal series of
stellar activity indicators. Aims. Here, we use the circular polarization in
near-infrared spectral lines for a sample of 43 quiet M dwarfs and compare the
measured rotation periods to those obtained with other methods. Methods. From
Stokes V spectropolarimetric sequences observed with SPIRou at CFHT and the
data processed with the APERO pipeline, we compute the least squares
deconvolution profiles using different masks of atomic stellar lines with known
Land\'e factor appropriate to the effective temperature of the star. We derive
the longitudinal magnetic field to examine its possible variation along the 50
to 200 observations of each star. For determining the stellar rotation period,
we apply a Gaussian process regression enabling us to determine the rotation
period of stars with evolving longitudinal field. Results. Among the 43 stars
of our sample, we were able to measure a rotation period for 27 stars. For 8
stars, the rotation period was previously unknown. We find a good agreement of
our rotation periods with periods found in the literature based on photometry
and activity indicators and confirm that near-infrared spectropolarimetry is an
important tool to measure rotation periods, even for magnetically quiet stars.
Furthermore, we compute ages for 20 stars of our sample using gyrochronology