When you type an illegal npm
command, you are getting a user-friendly error message stating which commands are legal to use:
$ npm illegal Usage: npm <command> where <command> is one of: add-user, adduser, apihelp, author, bin, bugs, c, cache, completion, config, ddp, dedupe, deprecate, docs, edit, explore, faq, find, find-dupes, get, help, help-search, home, i, info, init, install, isntall, issues, la, link, list, ll, ln, login, ls, outdated, owner, pack, prefix, prune, publish, r, rb, rebuild, remove, repo, restart, rm, root, run-script, s, se, search, set, show, shrinkwrap, star, stars, start, stop, submodule, tag, test, tst, un, uninstall, unlink, unpublish, unstar, up, update, v, version, view, whoami
As you may notice, among others there is isntall
command.
What is the point of this command? If this was created to handle typos, then why doesn't it have a special handling for intall
, insatll
etc? Besides, uninstall
doesn't have a corresponding unisntall
option.
(Using npm 1.3.22
version).
The reason I ask is that I'm a bit surprised and confused about how the typo is handled. For example, git
compares the command you've entered and suggests the closest commands it has available:
$ git stats git: 'stats' is not a git command. See 'git --help'. Did you mean this? status
Also, pip
Python package manager has a similar functionality built-in:
$ pip isntall ERROR: unknown command "isntall" - maybe you meant "install"
FYI, under-the-hood it uses difflib.get_close_matches()
function.