Running npm command within Visual Studio Code

Install

  • Ctrl+P, write ext install npm script runner
  • Restart VS Code

Use (two ways)

  • Ctrl+R Shift+R
  • Ctrl+P, write >npm, select run script, select the desired task

Update: Since version 1.3 Visual Studio Code has integrated terminal. To open it, use any of these methods:

  • Use the Ctrl+` keyboard shortcut.
  • Use the View | Toggle Integrated Terminal menu command.
  • From the Command Palette (Ctrl+Shift+P), use the View:Toggle Integrated Terminal command.

You can run npm commands directly in terminal (ctrl + `). Make sure that terminal has cmd.exe as the shell selected.

You can default cmd.exe as your shell by following these steps.

  1. ctrl+Shift+p
  2. Type > Select Default Shell + Enter
  3. Select > Command Prompt ...cmd.exe
  4. Restart VS Code.

There might be a chance that you have install node.js while your visual studio code was open. Once node.js is install successfully, Simply close the VS Code and Start it again. It will work. Thank you


On Win10 I had to run VSCode as administrator to npm commands work.


All you need to do is to add args to the integrated terminal within 'User Settings' window.

Follow this steps below to do that:

  1. List item
  2. Go to 'User Settings'
  3. Search for setting named - "terminal.integrated.shellArgs.windows"
  4. Edit this setting by copying it to the right side.
  5. Add the following arg value = "/k nodevars.bat", e.g. "terminal.integrated.shellArgs.windows": ["/k nodevars.bat"],
  6. Make sure that the setting named "terminal.integrated.shell.windows" is set to the value - "C:\Windows\system32\cmd.exe". If not then do that.
  7. Open new Terminal.

Good luck