How to get the npm global path prefix?

0 votes
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?
Oct 15 in Node-js by kartik
• 35,720 points
73 views

1 answer to this question.

0 votes

Hello @kartik,

Try this:

npm config get prefix will return the path.

Hope it helps!!

answered Oct 15 by Niroj
• 77,920 points

Related Questions In Node-js

0 votes
1 answer

How to get the server's port?

Hello @kartik, I use this way Express 4: app.listen(1337, ...READ MORE

answered Jul 16 in Node-js by Niroj
• 77,920 points
37 views
0 votes
1 answer

How to get the _id of inserted document in Mongo database in NodeJS?

Hello @kartik, A shorter way than using second ...READ MORE

answered Sep 7 in Node-js by Niroj
• 77,920 points
655 views
0 votes
1 answer

How to get the available tasks list in gulp?

Hello @kartik,  I got it use the gulp --tasks in ...READ MORE

answered Oct 13 in Node-js by Niroj
• 77,920 points
24 views
0 votes
1 answer

How to find the version of an installed node.js/npm package?

Hello, npm view <package> version - returns the latest ...READ MORE

answered 2 days ago in Node-js by Niroj
• 77,920 points
8 views
0 votes
1 answer

How to write files in Node.js?

Hello @kartik, Currently there are three ways to ...READ MORE

answered Jul 8 in Node-js by Niroj
• 77,920 points
97 views
0 votes
1 answer

How to Install a local module using npm?

Hello @kartik, This is what worked for me: npm ...READ MORE

answered Jul 9 in Node-js by Niroj
• 77,920 points
103 views
0 votes
1 answer

How to run Gulp tasks sequentially one after the other?

Hello @kartik, By default, gulp runs tasks simultaneously, ...READ MORE

answered Jul 12 in Node-js by Niroj
• 77,920 points
65 views
0 votes
1 answer

How to set environment variables from within package.json?

Hello @kartik, Set the environment variable in the ...READ MORE

answered Jul 13 in Node-js by Niroj
• 77,920 points
2,805 views
0 votes
1 answer

How do I get the path to the current script with Node.js?

Hello @kartik, you can do this: fs.readFile(path.resolve(__dirname, 'settings.json'), 'UTF-8', ...READ MORE

answered Jul 8 in Node-js by Niroj
• 77,920 points
546 views
0 votes
1 answer

How to get path from the request in nodejs?

Hello @kartik, Try this out: var http = require('http'); var ...READ MORE

answered Oct 14 in Node-js by Niroj
• 77,920 points
28 views