How To Change Global Node Modules Folder Path

My work PC is configured to login using active directory. It synchronizes all the changes before I login and after I log off. Sometimes, it takes a very long time to sync the profile, especially when the content inside my personal folders (like, My Documents, desktop, etc.), is very large (in GBs). So, I like to keep my profile data as low as possible, to maintain a faster login experience.
 
So, it happened the previous day. I installed several node modules using npm command line tool and logged off. When I logged in after awhile, it took so much time to login and I had no idea what had gone wrong. So I guessed (and I was right) that it is because of the last thing I did in my PC, i.e., Node and Node Modules. Then, I learned about the location of the global Node Modules folder.
 
"%UserProfile%/appdata/roaming/npm/node_modules" 
 
What I learned is that every time you install a node module in global mode (for example: "npm install -g express"), it is saved in the user profile's roaming folder.
 
 
 
So, I checked with node.js documentation and found that it can be changed very easily using a simple "npm config"  command.
 
Command to set Global Node Modules folder
 
npm config set prefix "<desired folder path>"
 
For example: npm config set prefix "E:\node_modules",
 
 
 
From the next time onward, every global installation will save the node modules in "E:\node_modules" folder. I moved all the node modules from roaming folder to the new location and my login became as fast as before.
Next Recommended Reading
Running JavaScript Files in Node.js