13

I'm developing a large client-side javascript app, which requires a complex tree of Javascript dependencies, all of which are available as npm modules. Most modules I require are not available as nugets, I'd like to get it so adding npm modules to my webapp is as simple as adding nugets.

Is it possible/reasonable to use npm to install packages "into" my ASP.NET MVC project?

Seth
  • 2,712
  • 3
  • 25
  • 41

4 Answers4

7

You can check Bower. That is client package manager. It suits for asp.net mvc. Here some help:

Community
  • 1
  • 1
Artyom
  • 3,507
  • 2
  • 34
  • 67
5

npm support has been added to Visual Studio as of 2013 update 3:

http://www.hanselman.com/blog/IntroducingGulpGruntBowerAndNpmSupportForVisualStudio.aspx

Laura
  • 66
  • 1
  • 2
1

You can now install packages by adding "Package.json" into your ASP MVC project and then add the packages you need. Visual Studio will install based on the packages included in your "Package.json" file.

JeeShen Lee
  • 3,476
  • 5
  • 39
  • 59
1

Microsoft provide a tutorial for using NPM modules in visual studio projects: https://learn.microsoft.com/en-us/visualstudio/javascript/npm-package-management?view=vs-2022#aspnet-core-projects

Notice that, for ASP.NET projects, guidance is only given for Core projects and not MVC projects, showing that MVC projects don't natively support NPM.

I have not managed to use any other packages to set up NPM inside ASP.NET MVC projects, and have found that the best solution is to migrate the project over to Core, which Microsoft give a tutorial for (references to ASP.NET on its own generally refer to the MVC version) : https://learn.microsoft.com/en-us/aspnet/core/migration/proper-to-2x/?view=aspnetcore-7.0

Ben H
  • 21
  • 4