How to use NPM and install packages inside Visual Studio 2017?
To avoid navigating manually to the correct directory use the "Open Command Line" extension from Mads Kristensen. It is available for free in the Marketplace. You find it here.
Once installed you can open a command prompt conviently directly from within Visual Studio.
Tipp: Use the Keyboard Shortcut ALT+Space instead of the context menu to open the command prompt.
You can then run your npm command:
npm install react-bootstrap-typeahead
As a side note: As of npm 5.0.0, installed modules are added as a dependency by default, so the --save option is no longer required.
Update 2019:
Developer Command Prompt and Developer Power Shell are now integrated into Visual Studio 2019 ( 16.2 Preview 2 ) - no need for an extension anymore.
You find them under Tools/Command Line
By default no shortcut is assigned - so you have to do this yourself.
You can use the Package Manager Console to run npm command.
To open the Package Manager Console, go to Tools > Nuget Package Manager and select Package Manager Console and then enter your npm command.
Update:
The latest visual studio 16.8.3 onwards, you will find the terminal built into visual studio.
You can find it by right-clicking at your solution or a shortcut Ctrl
+ `
:
I think the easiest way is to simple use the UI, Visual Studio provides.
Create in the root of your project a package.json
(Todo so, right click your project, add item and search for NPM
. You will find a npm Configuration File
):
{
"name": "SomeName",
"version": "1.0.0",
"private": true,
"devDependencies": {
"react-bootstrap-typeahead": "*"
}
}
Note that *
is for the latest version. This is not recommended. Better to specify the version you want. You will notice, that you have support of intellisence for versions and package names.
Everytime you make changes to the json file, simple press CTRL + S. Visual Studio automaticly calls NPM and restores the packages.
For how to use the command line, other have already answerd. But as being a command line noob myself, I prefer this way.