About the bin file in the npm project

recently, when I looked at the vue-cli 2.9.0 source code, I saw that some instructions were defined in the vue file under the bin file

-sharp!/usr/bin/env node

require("commander")
  .version(require("../package").version)
  .usage("<command> [options]")
  .command("init", "generate a new project from a template")
  .command("list", "list available official templates")
  .command("build", "prototype a new project")
  .parse(process.argv)

there are also vue-init, vue-list and other files in the bin folder.
I would like to ask why, after defining the init instruction in commander, you can type the vue init instruction on the command line to execute the code in vue-init. This is what kind of implementation principle, or npm did it for us.

Jul.02,2021

what you should see is here and the corresponding source code

.

description in README

The commander will try to search the executables in the directory of the entry script (like. / examples/pm) with the name program-command, like pm-install, pm-search

you just look at the place where the command is received, and of course you don't know what vue init executes.

vue-cli/blob/dev/packages/@vue/cli/bin/vue.js-sharpL127

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38810-2c136.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38810-2c136.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?