[英]How to configure npm package so that global install puts it on the path?
I've got a node module that I'm trying to publish as a global NPM package, so that when you install with -g, it puts a couple commands in the path automatically. 我有一个节点模块,我想将其发布为全局NPM软件包,以便在使用-g进行安装时,它会自动在路径中放置几个命令。
In this case my module is called ncrypt-stream and it has two commands -- node encrypt.js and node descrypt.js -- I want to be able to run these commands by simply typing encrypt or decrypt from anywhere in the file system. 在这种情况下,我的模块称为ncrypt-stream ,它有两个命令-节点crypto.js和节点descrypt.js-我希望能够通过简单地从文件系统中的任何位置键入crypto或解密来运行这些命令。
I know this package is probably reinventing the wheel: it is a learning exercise more than anything. 我知道此程序包可能正在重塑方向:它是一项学习活动,比什么都重要。
Thanks! 谢谢!
Just use the bin
option in your package.json
to specify binaries. 只需在package.json
使用bin
选项来指定二进制文件即可。
https://docs.npmjs.com/files/package.json#bin https://docs.npmjs.com/files/package.json#bin
{ "bin" : { "myapp" : "./cli.js" } } {“ bin”:{“ myapp”:“ ./cli.js”}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.