6

我正在尝试使用 npx 执行范围包。似乎唯一的方法是直接指定包,例如:

npx -p @foo/bar bar

这将正确下载@foo/bar并运行我的“bin”部分bar中的条目:package.json

"bin": {
    "bar": "./cli.js"
}

但是,我真正想要的是输入以下内容:

$ npx @foo/bar
npx: installed 1 in 4s
npx: command not found: bar

我试过@foo/bar, foo/bar,bar在该bin部分,没有运气。npx 是否支持这样的范围包?

4

1 回答 1

4

OK, it looks like scoped packages work as long as you don't export any alternate commands. That is, you cannot use the object form and must instead specify only one bin command:

{
    "name": "@foo/bar",
    ...,
    "bin": "./cli.js"
}
于 2019-10-31T18:49:32.753 回答