Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the npm global path prefix

Tags:

node.js

npm

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?

like image 420
Dmitry Minkovsky Avatar asked Aug 22 '13 14:08

Dmitry Minkovsky


People also ask

What is the default npm prefix?

The default on OS X is /usr/local , which means that npm will symlink binaries into /usr/local/bin , which should already be on your PATH (especially if you're using Homebrew).

What is prefix in npm config?

prefix. This is the location where global items are installed, which by default is the install location of npm itself. If prefix is set on the command line, then non-global commands are forced to run in the given folder.

How do I find the path of a node?

The first method to get the path of the current directory is the __dirname method. This is a Node. js core module that gets the current path of whatever directory the JavaScript file or module is running in. And you can also get the same result by using the path.

Where is npm config file?

Built-in npm config file: /path/to/npm/npmrc.


1 Answers

npm config get prefix will return the path.

like image 72
fakewaffle Avatar answered Sep 17 '22 13:09

fakewaffle