pnpm is an alternative package manager for Node.js. It is a drop-in replacement for npm, but faster and more efficient.
So how does pnpm structure the node_modules directory, if not by flattening? To understand it, we should recall how did the node_modules folder look like before npm version 3. Prior to npm@3, the node_modules structure was predictable and clean, as every dependency in node_modules had its own node_modules folder with all of its dependencies specified in package.json.