npm bin 命令 - 未被识别为内部或外部命令 [英] npm bin command - not recognized as an internal or external command
问题描述
我在使用 bin 命令时遇到问题.如果我正确理解 documentation 然后从 bin 运行命令后它应该执行文件
i'm having problem with bin command. If I understand documentation correctly then after runing command from bin it should execute the file
所以在我的情况下 package.json
看起来像:
So in my case package.json
looks like:
"author": "Andurit",
"license": "contact author",
"bin": {
"shared-lib": "./node_modules/shared-lib-cli/bin/index.js"
},
所以我希望命令行中的 shared-lib
将执行 ./path/bin/index.js
So I would expect that shared-lib
in command line will execute ./path/bin/index.js
相反,我收到一个命令行错误:
Instead of that, I'm getting a command line error:
shared-lib 不被识别为内部或外部命令.
shared-lib is not recognized as an internal or external command.
我想用它做什么:
index.js
是某种解析器,它将构建我的库的自定义构建.你可以把它想象成类似于 lodash custom build
index.js
is some kind of parser which will build custom build of my library. You can imagine that as something similar as lodash custom build
所以我通常像node ./path/bin/index.js category=category1,category2
我希望它如何工作:
shared-lib category=category1,category2
伙计们,我是不是误解了 bin
函数,我应该寻找其他东西,还是您遇到过 Windows(在我的情况下为 7)不接受您的 bin 命令的情况?>
Guys, did I misunderstand the bin
function and should I look for something else or does it ever happen to you that Windows (7 in my case) doesn't accept your bin command?
推荐答案
Okey 找出问题所在,npm install
应该全局运行例如npm install -g
Okey find out where is a problem, npm install
should be runned globaly
e.g. npm install -g
我注意到我的 package.json 中有 "preferGlobal": true,
但是它看起来不像预期的那样工作.
I noticed I have in my package.json "preferGlobal": true,
however it looks it doesnt work as expected.
这篇关于npm bin 命令 - 未被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!