NodeJS - Npm - set global node_modules
Ever had the problem of 'XXXXX'('yarn') is not recognized as an internal or external command ?!
The solution is as follows:
mkdir %PROGRAMDATA%\npm setx PATH "%PROGRAMDATA%\npm;%PATH%" /M npm config set prefix %PROGRAMDATA%\npm
- Create a folder in a sensible location to hold the globals (Microsoft is adamant that you shouldn't write to ProgramFiles, so %PROGRAMDATA% seems like the next logical place.
- The directory needs to be on the path, so use
setx .. /Mto set the system path (under HKEY_LOCAL_MACHINE). This is what requires you to run this in a shell with administrator permissions.
npmto use this new path. (Note: folder isn't visible in %PATH% in this shell, so you must open a new window).
npm config ls -l | grep prefix -> This is to list all node_modules configured ...