Context : Multi-planet systems are excellent laboratories to test planet formation models , since all planets are formed under the same initial conditions . In this context , systems transiting bright stars can play a key role , since planetary masses , radii , and bulk densities can be accurately measured . Aims : GJ 9827 ( K2-135 ) has recently been found to host a tightly packed system consisting of three transiting small planets whose orbital periods of 1.2 , 3.6 , and 6.2 days are near the 1:3:5 ratio . GJ 9827 hosts the nearest planetary system ( d = 30.32 \pm 1.62 pc ) detected by Kepler and K2 . Its brightness ( V = 10.35 mag ) makes the star an ideal target for detailed studies of the properties of its planets . Methods : Combining the K2 photometry with high-precision radial-velocity measurements gathered with the FIES , HARPS , and HARPS-N spectrographs we revise the system parameters and derive the masses of the three planets . Results : We find that GJ 9827 b has a mass of M _ { \mathrm { b } } = 3.74 ^ { +0.50 } _ { -0.48 } M _ { \oplus } and a radius of R _ { \mathrm { b } } = 1.62 ^ { +0.17 } _ { -0.16 } R _ { \oplus } , yielding a mean density of \rho _ { \mathrm { b } } = 4.81 _ { -1.33 } ^ { +1.97 } { g cm ^ { -3 } } . GJ 9827 c has a mass of M _ { \mathrm { c } } = 1.47 ^ { +0.59 } _ { -0.58 } M _ { \oplus } , radius of R _ { \mathrm { c } } = 1.27 ^ { +0.13 } _ { -0.13 } R _ { \oplus } , and a mean density of \rho _ { \mathrm { c } } = 3.87 _ { -1.71 } ^ { +2.38 } { g cm ^ { -3 } } . For GJ 9827 d we derive M _ { \mathrm { d } } = 2.38 ^ { +0.71 } _ { -0.69 } M _ { \oplus } , R _ { \mathrm { d } } = 2.09 ^ { +0.22 } _ { -0.21 } R _ { \oplus } , and \rho _ { \mathrm { d } } = 1.42 _ { -0.52 } ^ { +0.75 } { g cm ^ { -3 } } . Conclusions : GJ 9827 is one of the few known transiting planetary systems for which the masses of all planets have been determined with a precision better than 30 % . This system is particularly interesting because all three planets are close to the limit between super-Earths and mini-Neptunes . We also find that the planetary bulk compositions are compatible with a scenario where all three planets formed with similar core/atmosphere compositions , and we speculate that while GJ 9827 b and GJ 9827 c lost their atmospheric envelopes , GJ 9827 d maintained its atmosphere , owing to the much lower stellar irradiation . This makes GJ 9827 one of the very few systems where the dynamical evolution and the atmospheric escape can be studied in detail for all planets , helping us to understand how compact systems form and evolve .