There are many ways to create a node_modules directory. Your goal must be to create the most strict one but if that is not possible, there are options to make a loose node_modules as well.
New users of pnpm frequently ask me about the weird structure of
node_modules that pnpm creates. Why is it not flat? Where are all the sub-dependencies?