node.js 如何获取 npm 全局路径前缀
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18383476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the npm global path prefix
提问by Dmitry Minkovsky
I believe that in the past I've discovered an option to pass to npmto 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 npmis using?
我相信过去我发现了一个选项可以传递给npm它来输出它用于-g(全局模块)的路径。有谁知道这样的选择?或者使用任何其他方法来获取全局路径前缀npm?
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 $PATHis correctly configured, and if not, well, poking around does the trick. But isn't there be some quick way to tell how npmwas built, and which path it's using for globals modules?
我知道全局模块在我的计算机上的位置 ( /usr/local/share/npm/bin),并且通常只需几分钟即可在其他计算机上找到全局模块:通常$PATH配置正确,如果没有,那么,四处看看就可以了。但是,难道没有一些快速的方法可以说明npm是如何构建的,以及它用于全局模块的路径吗?
回答by fakewaffle
npm config get prefixwill return the path.
npm config get prefix将返回路径。
回答by Mateusz Jagie??o
How about npm bin?
怎么样npm bin?
It can be used with export PATH="$(npm bin):$PATH". It will find npm's binglobal directory (or if exist: local).
它可以与export PATH="$(npm bin):$PATH". 它将找到 npm 的bin全局目录(或者如果存在:本地)。

