How to get the npm global path prefix

node.jsNpm

node.js Problem Overview


I believe that in the past I've discovered an option to pass to npm to get it to output the path it is using for -g (global modules). Does anyone know such an option? Or any other method to get the global path prefix npm is using?

I know where where the global modules live on my computer (/usr/local/share/npm/bin), and generally it only takes a few minutes to find global modules on other computers: usually $PATH is correctly configured, and if not, well, poking around does the trick. But isn't there be some quick way to tell how npm was built, and which path it's using for globals modules?

node.js Solutions


Solution 1 - node.js

npm config get prefix will return the path.

Solution 2 - node.js

How about npm bin?

It can be used with export PATH="$(npm bin):$PATH". It will find npm's bin global directory (or if exist: local).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDmitry MinkovskyView Question on Stackoverflow
Solution 1 - node.jsfakewaffleView Answer on Stackoverflow
Solution 2 - node.jsMateusz JagiełłoView Answer on Stackoverflow