I've built a fairly hacky solution to this before (for a different package manager) - it can be pretty simple:
node_modules/
versions/
a@1.0.0
node_modules/
c -> ../../c@1.0.0
b@1.0.0
node_modules/
c -> ../../c@1.0.0
c@1.0.0/
c@2.0.0/
a -> versions/a@1.0.0
b -> versions/b@1.0.0
c -> versions/c@2.0.0