简体   繁体   English

使用npm运行全局安装的npm程序

[英]run global installed npm programs with npm

So you have npm bin -g that yields the bin directory where npm installs stuff. 因此,您有npm bin -g生成bin目录,npm在该目录中安装了东西。 Is there a way to use npm to run stuff from that directory? 有没有一种方法可以使用npm从该目录运行内容? An obvious option would be $(npm bin -g)/installednodeprogram but I am calling this from an external program (emacs) and would like to avoid bringing up a shell. 一个明显的选择是$(npm bin -g)/installednodeprogram但是我从外部程序(emacs)调用它,并且希望避免出现shell。 Also I could get the path from npm bin -g and then concatenate the program name and do all sorts of checks but I hope there is a cleaner way I couldn't find like npm run-binary installednodeprogram . 我也可以从npm bin -g获取路径,然后连接程序名称并进行各种检查,但我希望有一种更干净的方法,找不到npm run-binary installednodeprogram

If you've installed a program globally, you can run its command from the shell just like any other. 如果已全局安装了程序,则可以像其他任何程序一样从shell运行其命令。 In fact, that's what the npm command itself is. 实际上,这就是npm命令本身。

For example: 例如:

npm install -g browserify
browserify file.js # browserify command is now available

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

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