w3resource

Npm-explore, npm-help and npm-help-search cli options


In the previous tutorial we looked at the npm-docs, npm-doctor and npm-edit cli options, the tutorial you are about to read will examine npm's explore, help and help-search cli options.

npm-explore

The npm-explore command will browse an installed package.

Synopsis

npm explore <pkg> [ -- <command>]

Description

This cli option will spawn a subshell in the directory of the installed package specified. If there is a command that is specified, then it will run in the subshell, which will immediately terminate.

It is particularly handy in the case of git submodules in the node_modules folder:

npm explore some-dependency -- git pull origin master

it should be noted that the package will not be automatically rebuilt afterwards, so ensure that you use npm rebuild <pkg> if you make any changes.

Configuration

shell

This is the shell command used to run the npm explore command.

  • Default: SHELL environment variable, or "cmd" on Windows, or "bash" on Posix.
  • Type: path

npm-help

When you need to get help on npm, you should run this command.

Synopsis

npm help <term> [<terms..>]

Description

When a topic is supplied to this option, it will show the appropriate documentation page.

If the topic doesn't exist, or if you provide multiple terms, then you have to run the help-search command to find a match. It should be noted that if a single subject is found by help-search, it will run help on that topic, hence, unique matches are equivalent to specifying a topic name.

Configuration

Viewer

This indicates the program that will be used to view the help content.

You should set this to "browser" to view html content in the default web browser.

npm-help-search

This CLI option is used to search the npm help documentation.

Synopsis

npm help-search <text>

Description

This npm-help-search command will search the npm markdown documentation files for the terms provided, and then it will list the results, sorted by relevance.

In the case where only one result is found, then it shows that help topic.

Where the argument to npm help is not a known help topic, then it calls help-search. It is rarely ever necessary to call this command directly, as it will be triggered when npm help fails.

Configuration

Long

If this is true, then the long flag causes help-search to output context around where the terms were found in the documentation.

In the case where it is false, then help-search will just list out the help topic that it found.

  • Type: Boolean
  • Default: false

Previous: npm-docs, npm-doctor and npm-edit cli options
Next: npm-hook and npm-init cli options



Follow us on Facebook and Twitter for latest update.