Relationship between molar mass and density in solids In ideal gases, it's pretty clear that 1 mole of gas occupies 22.4 L at STP. By knowing this, it's easy to calculate density given molar mass. However, this isn't true for solids. If I know molar mass of a solid, I cannot derive it's density.
I want to clarify whether my understanding of why we can't derive density in case of solids is correct. For solids, since each solid has its own lattice structure, knowing how the molecules are arranged is necessary, because if there is more space between molecules, it will have a lower density, which isn't really an issue in (ideal) gases where the arrangement of molecules/atoms is uniform.
If your sample is solid and crystalline, knowledge of the unit cell's dimension and symmetry (e.g., fcc) and density allows you to determine the molecular mass of your compound.
In fact, in crystallography, you may determine the macroscopic density of your sample (e.g., find a liquid which i) wets your crystals and ii) lets your crystals float) in first place.  If you then know the dimensions of the unit cell by the diffraction experiment, knowledge of the chemical formula per unit cell may tell you the number of formula units per unit cell.  See e.g, this demonstration about Ne.
The example above about Ne may be extended to crystals consisting of molecules for that you may assign atomic volumes to each element that add up to a molecular volume. An early approximation for organic compounds[1] was to assign $\pu{18 Å^3}$ for any atom of $(\ce{C, N, O})$ and $\pu{2 Å^3}$ for any atom of $\ce{H}$.  Decades later,[2] backed by much more experimental data, it was possible to refine these assignments, e.g., to average volumes of $\pu{13.87 Å^3}$ ($\ce{C}$), $\pu{11.8 Å^3}$ ($\ce{N}$), $\pu{11.39 Å^3}$ ($\ce{O}$), and $\pu{5.08 Å^3}$ ($\ce{H}$), respectively.  Large deviations from these guesses from the then experimentally determined molecular volume may be caused by solvent-accessible voids in the crystal structure.[3]
References:
1 Kempster, C. J. E.; Lipson, H., A rapid method for assessing the number of molecules in the unit cell of an organic crystal in Acta. Cryst. B28, 1972, 3674; doi: 10.1107/S056774087200857X.
2 Hofmann, D. W. M., Fast estimation of crystal densities in Acta. Cryst. B58, 2002, 489-493; doi: 10.1107/S0108768101021814.
3 Florence, A. J., The use of supplementary information to solve crystal structures from powder diffraction in International Tables for Crystallography (2019). Vol. H. ch. 4.4, pp. 433-441; doi: 10.1107/97809553602060000959.