with npm root command, we can locates the local and global node_modules
directory.
Finding local dependencies isn’t very spectacular because they’re usually located in ./node_modules
. But locating the global dependencies can be a hassle. People install Node.js in countless ways, and that’s why the Node.js binary and the global dependencies can be anywhere.
fortunately, there’s a command that helps locate the global dependencies :
npm root -g
But what now, if we want to change the location ?
How To Change Global Node Modules Folder Path
npm config set prefix "<desired folder path>"
For example: npm config set prefix “c:\brice\node_modules“,
From the next time onward, every global installation will save the node modules in “c:\brice\node_modules” folder.