How to get the npm global path prefix

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?


Solution 1:

npm config get prefix will return the path.

Solution 2:

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).