http://sandervanderburg.blogspot.hk/2016/09/simulating-npm-global-package.html
http://sandervanderburg.blogspot.hk/2016/02/managing-npm-flat-module-installations.html

Huh, apparently npm2nix and the successor node2nix are younger than I thought. I didn't use node or nix before 2016, so for me they've always been there. :-)

This was how it was done before van der Burg developed the tools:

http://sandervanderburg.blogspot.hk/2016/08/porting-node-simple-xmpp-from-nodejs.html