22

I am getting a bit confused here.

I have an MVC 5 project, I want to use the npm for managing my javascript packages.

I installed npm from nuget and here i am stuck, I cant find the commandline console window or anything like that.

All the info i see online is about node projects.

Can someone direct me to a relevant tutorial.

Using visual studio 2013, MVC 5.

1

1 Answer 1

13

Well regardless of the project, if you want to use npm on Windows, this is what you need:

  1. Download and install Node (you might need a restart).
  2. Make sure that node is installed by opening a command prompt and running node -v (should print a version number).
  3. Run npm -v and see if it's installed (should be).

Now in the context of an ASP.NET MVC project. The newer versions of Visual Studio (I believe 2015) support npm - you can just open the package.json and add dependencies (it will download them behind the scenes). In case you're using an old version, you can simply open a command prompt, navigate to your project and use npm install from there.

Sign up to request clarification or add additional context in comments.

4 Comments

Are you sure about this? Even in 2017 it seems to be a manual process or rely upon third party extensions and configuration
@IronSean I have to admit, I use VSCode for node projects, however I just opened VS2017 and although a bunch of things have changed, I still see plenty of integrations (Add New Item -> npm Configuration File), or right-click on a package.json file and "restore packages", or open the package.json and right click on individual packages/dependencies and update/uninstall them or go to their homepage etc. Also autocomplete packages when you type them (along with their version). So ya I think this still applies. Do you have anything specific in mind?
How is this meant to work when publishing an ASP.NET MVC 5? In my project I am referencing the node_modules folder in my BundleConfig. When I publish the files the contents of the node_modules doesn't come with it because it's not part of my solution.
@CiaranGallagher Typically you would have a build setup that bundles your app in a JS output file (webpack for example) and you deploy that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.