I always develop inside a virtual machine, with a shared folder in between so I can write code on the host, but everything runs in the guest.
Admittedly this is more of a discussion about containers and security than npm itself but I'm interested in discovering the options out there. I may attempt to move all my stuff to containers for a bit and write about my findings.
Huzzah for git.