node.js - 作为命令行程序的 npm 包的 Shell 脚本包装器

标签 node.js npm

假设您有一个 npm 包,您希望将其用作命令行程序,例如js-美化。

当我全局安装它时,我发现确实有一个附带的 Windows 批处理文件,实际上是在不同目录中具有相同名称的两个稍有不同的批处理文件(以及安装在 UNIX 上时的 shell 脚本) 。

但是当我查看 github 上的 js-beautify 源代码时,没有任何批处理文件的迹象。批处理文件从哪里来?我在 npm 文档中没有看到任何提及此类内容。

最佳答案

当您将 package.json 中的“bin”属性配置为 js-beautify does here 时,就会发生这种情况。 。具体来说,npm install 使用 cmd-shim模块将它们创建为 shown here .

关于node.js - 作为命令行程序的 npm 包的 Shell 脚本包装器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30426294/

相关文章:

javascript - gulp:自动为请求添加版本号以防止浏览器缓存

node.js - 如何撤消 npm 更新?

javascript - 无法使用 npm 安装 gatsby-plugin-transition-link

node.js - Express res header 事件不再触发

node.js - 如何在nodejs中保存通过api上传的文件

node.js - Knex.js 多个 orderBy() 列

javascript - 出现错误 Socket 正在尝试重新连接到 Sails

laravel 5 vue.js csrf token

node.js - 错误 : spawn/data/craft/templates/node_modules/optipng-bin/vendor/optipng ENOENT

javascript - NodeJs 中的参数未通过 Request 传递