运行 npx 与范围包
running npx with scoped packages
我正在尝试使用 npx 执行作用域包。似乎唯一的方法是直接指定包,例如:
npx -p @foo/bar bar
这将正确下载 @foo/bar
和 运行 我的 package.json
"bin" 部分中的 bar
条目:
"bin": {
"bar": "./cli.js"
}
但是,我真正想要的是输入:
$ npx @foo/bar
npx: installed 1 in 4s
npx: command not found: bar
我在 bin
部分尝试了 @foo/bar
、foo/bar
、bar
,但没有成功。 npx 是否支持这样的范围包?
好的,只要您不导出任何备用命令,范围内的包似乎就可以工作。也就是说,您不能使用对象形式,而只能指定一个 bin 命令:
{
"name": "@foo/bar",
...,
"bin": "./cli.js"
}
我正在尝试使用 npx 执行作用域包。似乎唯一的方法是直接指定包,例如:
npx -p @foo/bar bar
这将正确下载 @foo/bar
和 运行 我的 package.json
"bin" 部分中的 bar
条目:
"bin": {
"bar": "./cli.js"
}
但是,我真正想要的是输入:
$ npx @foo/bar
npx: installed 1 in 4s
npx: command not found: bar
我在 bin
部分尝试了 @foo/bar
、foo/bar
、bar
,但没有成功。 npx 是否支持这样的范围包?
好的,只要您不导出任何备用命令,范围内的包似乎就可以工作。也就是说,您不能使用对象形式,而只能指定一个 bin 命令:
{
"name": "@foo/bar",
...,
"bin": "./cli.js"
}