npm package.json bin won't work on Windows

前端 未结 4 649
天涯浪人
天涯浪人 2021-02-12 11:39

I am trying to start my cli tool via the package.json bin property.

I have the following:

...
\"name\": \"mycli\",
\"bin\": \"./bin/mycli\",         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-12 12:22

    Try to specify the name of your cli tool in the bin property, like:

    "bin": {
      "mycli": "./bin/mycli" // or "/bin/mycli.js" if it's a .js file
    }
    

    Then, run npm link, from inside your project folder, to create a global symbolic link to the current folder.

    Don't forget to add the "preferGlobal": "true" property just before the bin property in your package.json file, in order to warn users to install your module globally.

提交回复
热议问题