In my windows installation PATH includes C:\\Program Files\\nodejs, where executable node.exe is. I\'m able to launch node
To Change the default global installation directory for node.js(npm) modules in Windows, You need to fix 2 paths.
First check the current path where node modules are installing, when you try to install them globally by using following command :
npm list -g --depth=0
It will return you the current path where node modules are installing right now. Example: D:\vsc\typescript
Now visit the following path to see npm and npm-cache folder. C:\Users\username(OR Number)\AppData\Roaming
In Roaming folder of your C drive you will find npm and npm-cache folder. Click on the + npm + folder and select the path[Just click on the bar path will be selected automatically, copy it ].This is a path image which you need to select
Once you copy this path set this to the environment variables, with a variable name Path(anything you can select as a name). Now you have set the path for your npm folder, now this is the time to set prefix. Go inside npm folder and check if node_module folder exist, if not create a new folder named as node_modules. You all global modules will come in this folder after completing all steps.
Final Step: Go to CMD and right the following command:
npm set prefix C:\Users\username(Number)\AppData\Roaming\npm\node_modules
Again this is the same path we selected for environment variable, we are just adding one more folder in the path and that is node_module.
All Set....Try Now...It will work..