npm bin command - not recognized as an internal or external command

旧巷老猫 提交于 2021-01-28 22:24:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!