IntelliJ IDEA 2016.1 Help

NPM Tool Window

Context menu of a package.json - Show npm Scripts
View | Tool Windows | npm
- the tool window can be accessed this way only after you have opened it using the Show npm Scripts command.

On this page:

Accessing the npm Tool Window

The tool window is available only when:

  1. The Node.js runtime environment is installed on your computer.
  2. The NodeJS repository plugin is installed and enabled. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
  3. At least one package.json file is available in the current project.

The tool window opens when you invoke npm by choosing Show npm Scripts on the context menu of a package.json in the Project tool window or of a package.json opened in the editor. Use the tool window to run npm scripts.

As soon as you invoke npm, it starts building a tree of scripts defined within the scripts property of the package.json file on which it was invoked. If you have several package.json files in your project, you can build a separate script tree for each of them and run scripts without abandoning the previously built trees. Each tree is shown under a separate node.

Building a Tree of npm Scripts

To build a tree of scripts, do one of the following:

  • Select the required package.json file in the Project tool window and choose Show npm Scripts on the context menu of the selection.
  • Open the required package.json file in the editor and choose Show npm Scripts on the context menu of the editor.
  • If the npm tool window is already opened, click add_black.png on the toolbar and choose the required package.json file from the list. IntelliJ IDEA adds a new node and builds a scripts tree under it. The title of the node shows the path to the package.json file according to which the tree is built.

Running npm Scripts

To run a script from the tree, do one of the following:

  • Double click the required script in the tree.
  • Select the required script and choose Run <script name> on the context menu of the selection.
  • Select the required script and press Enter.

The tool window shows the npm script output, reports the errors occurred, lists the packages or plugins that have not been found, etc. The name of the last executed script is displayed on the title bar of the tool window.

To run several scripts, use the multiselect mode: hold Shift (for adjacent items) or Ctrl (for non-adjacent items) keys and select the required scripts, then choose Run on the context menu of the selection.

Toolbar

ItemTooltipDescription
add_black Add package.json Click this button to have a tree of scripts for another package.json file built. Choose the required package.json file from the pop-up list. IntelliJ IDEA adds a new node and builds a tree of scripts under it it.
minusSign.png Remove package.json Click this button to remove the tree of scripts under the selected node.
icon_reload_grunt.png Reload scripts Click this button to have the tree of scripts under the selected node re-built. You may need a tree re-built after updating the corresponding package.json file because npm does not apply changes to trees on the fly.

Context Menu of a Tree

ItemDescription
npm Settings Choose this menu item to open the npm Settings dialog box and view or edit the Node.js configuration
Jump to Source Choose this menu item to open the package.json file for which the current tree is built.
Reload scripts Choose this menu item to have the tree of scripts under the selected node re-built.
Copy Path Choose this menu item to save the path to the package.json file according to which the current tree was built to the clipboard.
Remove package.json Choose this menu item to remove the tree of scripts under the selected node.

Context Menu of a Script

ItemDescription
Run <script name> Choose this menu item to run the selected script.
Edit <script name> settings Choose this menu item to open the Run/Debug Configuration dialog box and edit the predefined settings for the selected script.
Jump to Source Choose this menu item to open the package.json file for which the current tree is built and navigate to the definition of the selected script.

See Also

Last modified: 13 July 2016