问题
i'm having problem with bin command. If I understand documentation correctly then after runing command from bin it should execute the file
So in my case package.json
looks like:
"author": "Andurit",
"license": "contact author",
"bin": {
"shared-lib": "./node_modules/shared-lib-cli/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 is not recognized as an internal or external command.
What I want to use it for:
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
So I usually use it like node ./path/bin/index.js category=category1,category2
How I want it to work:
shared-lib category=category1,category2
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?
回答1:
Okey find out where is a problem, npm install
should be runned globaly
e.g. npm install -g
I noticed I have in my package.json "preferGlobal": true,
however it looks it doesnt work as expected.
来源:https://stackoverflow.com/questions/39037202/npm-bin-command-not-recognized-as-an-internal-or-external-command