Npm-ls and npm cli options

In the previous tutorial we examined how the npm-link, and npm-logout work, the tutorial you are about to read will cover the npm-ls and npm commands.


This command will list the installed packages in an environment, else it will return empty.


npm ls [[<@scope>/] ...]
aliases: list, la, ll


The npm ls command will print to stdout all the versions of a package that is installed, including their dependencies in a tree-structure.

Positional arguments serve as name@version-range identifiers, which limits the results to the packages path alone. It should be noted that nested packages also show the paths to the specified packages. For instance, if you run npm ls promzard in an npm source tree, you will get:

npm@@VERSION@ /path/to/npm
+-- [email protected]
  +-- [email protected]

It prints out extraneous, missing and invalid packages.

If your project specifies git urls for dependencies these are shown in parentheses after the name@version to make it easier for users to recognize potential forks of a project.

The tree shown will be the logical dependency tree, based on the package dependencies, and not the physical layout of your node_modules folder.

When you run it as ll or la, it will show extended information by default.



  • Default: false
  • Type: Boolean

Shows information in JSON format.


  • Default: false
  • Type: Boolean

This option shows the extended information.


  • Default: false
  • Type: Boolean

Show parseable output instead of tree view.


  • Default: false
  • Type: Boolean

Lists the packages in the global install prefix instead of in the current project.


Type: Int

This is the max display depth of the dependency tree.

prod / production

  • Type: Boolean
  • Default: false

Displays only the dependency tree for packages in dependencies.

dev / development

  • Type: Boolean
  • Default: false

Displays only the dependency tree for packages in devDependencies.


Type: String

When in "dev" or "development", this is an alias to dev.

When in "prod" or "production", this is an alias to production.


  • Type: Boolean
  • Default: false

Displays only dependencies which are linked


This is the javascript package manager.


npm <command> [args]


The package manager for the Node JavaScript platform, is npm. This puts modules in place so that node can find them, and it manages dependency conflicts intelligently.

Npm is configurable to support a wide variety of use cases. Most often, npm is used to publish, discover, install, and develop node programs.

Then, you should run npm help to get a list of available commands.


You probably got npm because you wanted to install something.

Run npm install blerg to install the latest version of "blerg". It does a lot of stuff.

Run the npm search command to show everything that is available. Then, run npm ls to show everything you've installed.


If a package references to another package that has a git URL, npm will depend on a preinstalled git.

If one of the packages npm attempts to install is a native node module and require that you compile a C++ Code, npm uses node-gyp for that task.


There are two modes of operations in npm:

  • global mode: npm will install packages into the install prefix at prefix/lib/node_modules and bins will be installed in prefix/bin.
  • local mode: npm will install packages into the current project directory, which will default to the current working directory. Packages that are installed to ./node_modules, and bins will be installed to ./node_modules/.bin.

The default is local mode. You should use -g or --global on any command to operate in the global mode instead.


If you're using npm to develop and publish your code, check out the following help topics:

  • json: Makes a package.json file. See package.json.
  • link: This is for linking your current working code into Node's path, so that you won't have to reinstall every time you make a change.
  • install: It is a good idea to install things if you don't need the symbolic link. Especially, if you are installing other peoples code from the registry is done via npm install
  • adduser: Creates an account or log in. Credentials will be stored in the user config file.
  • publish: Uses the npm publish command to upload your code to the registry.


npm is very configurable. It will read its configuration options from 5 places.

  • Command line switches: Sets a config with --key val. All keys will take a value, even when they are booleans (the config parser will not know what the options are at the time of parsing). If you don't provide a value, then the option will be set to boolean true.
  • Environment Variables: Will set any config by prefixing the name in an environment variable with npm_config_. For instance, export npm_config_key=val.
  • User Configs: The file at $HOME/.npmrc will be an ini-formatted list of configs. If present, it will be parsed. Whenever the userconfig option is set in the cli or env, then that is used instead.
  • Global Configs: This is the file that is found at ../etc/npmrc (from the node executable, by default this will resolve to /usr/local/etc/npmrc ) is parsed if it is found. If you set the globalconfig option is in the cli, env, or user config, then that file will beparsed instead.
  • Defaults: npm's default configuration options will be defined in lib/utils/config-defs.js. These should never be changed.

Previous: npm-link and npm-logout cli option
Next: Npm-outdated and npm-owner

Follow us on Facebook and Twitter for latest update.