简体   繁体   English

如何获取npm全局路径前缀

[英]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). 我相信在过去我发现了一个传递给npm的选项,让它输出它用于-g (全局模块)的路径。 Does anyone know such an option? 有谁知道这样的选择? Or any other method to get the global path prefix npm is using? 或者任何其他获取全局路径前缀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 $PATH is correctly configured, and if not, well, poking around does the trick. 我知道全局模块在我的计算机上的位置( /usr/local/share/npm/bin ),通常只需要几分钟就能在其他计算机上找到全局模块:通常$PATH配置正确,如果没有好吧,四处寻找诀窍。 But isn't there be some quick way to tell how npm was built, and which path it's using for globals modules? 但是,是不是有一些快速的方法来告诉如何构建npm ,以及它用于全局模块的路径?

npm config get prefix将返回路径。

How about npm bin ? npm bin怎么样?

It can be used with export PATH="$(npm bin):$PATH" . 它可以与export PATH="$(npm bin):$PATH" It will find npm's bin global directory (or if exist: local). 它将找到npm的bin全局目录(或者如果存在:local)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM