


Your package.json file will look something like that below with descriptive values set from the initialisation command and dependencies on any packages that you’ve installed. By default node_modules will be hidden so to view it you’ll need to enable the “Show All Files” option in the solution explorer. The package.json file will now be added to your project and the folder node_modules will be created and jQuery downloaded into it. Once npm has been initialised you can either add a configuration file manually and start adding packages from there or install a package from the command line and have it create the configuration file for you which is what I usually do, to install jQuery use npm install jquery -save. Open a command prompt scoped to your project folder and run npm init to initialise npm in your project, this will ask you for some basic details about your project but you can just accept the defaults and edit the values later in the configuration if you’d like. Preparationįirst off, install Node.js which will install npm for you.Īs per this article it’s easier to use npm from the command line and installing the extension “Open Command Line” means you can open a command prompt scoped to any folder in your solution from a right click. Using npm in Visual Studio takes a bit more work than Bower to setup but is better supported and gives more control over the library files that are published. By default new Web Applications created in Visual Studio 2017 use Bower for managing external libraries such as jQuery and Bootstrap, however Bower is no longer best practice (and seemed a bit flaky in Visual Studio anyway) and so for new projects I now use npm for managing packages.
