package.json 用于安装全局模块的脚本,如果缺少然后使用它

package.json script to install global module if missing and then use it

我想要一个 npm 脚本,它将:

我的 package.json 中会有一个脚本条目来执行此操作。

"scripts": {
    "exeglobal": "TODO: check to see if global package is installed, if not install it, then use it"
}

有人知道 OS 独立的方法吗?

您可以将模块添加到 devDependency 并像这样使用它。