Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"npm isntall" command exists

Tags:

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.

like image 922
alecxe Avatar asked Nov 18 '14 05:11

alecxe


People also ask

Why npm install command not found?

In most cases, this type of error occurs when the system cannot find the path where npm or NodeJS is installed. This could be because you don't have npm or NodeJS installed on your system or haven't configured the PATH to binaries.

What is npm install command?

Description. This command installs a package, and any packages that it depends on. If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven by that, with an npm-shrinkwrap. json taking precedence if both files exist.

How do you check if npm is already installed?

Test NPM. To see if NPM is installed, type npm -v in Terminal. This should print NPM's version number so you'll see something like this 1.4. 28.


1 Answers

I was the original "raiser" of the connected issue on Github, and those were the first days of contributing to OSS software... I thought it was just a typo, and maybe a pull request would solve it. But I was blessed with some good sense to first raise an issue (#2933) to find out if they were looking for contribution on that front...

As it turned out, it unravelled a whole discussion around the issue, which was good to see.

The raison d'être of the isntall command is because the npm maintainers believe that it saves them time — and thus, by extension — several other developers. As has been discussed in the linked issue, this was a contentious decision, and several people have suggested more interesting methods for resolving typos such as using the levenshtein distance calculation of the illegal command from valid npm commands (https://www.npmjs.org/package/levenshtein).

At any rate, I presume if you do implement one of those algos and contribute to the npm project, it would be a nice addition to this awesome library...

like image 158
kumarharsh Avatar answered Oct 24 '22 01:10

kumarharsh