How can I disable NPM package restore in Visual Studio 2015?

node.jsVisual StudioNpmVisual Studio-2015

node.js Problem Overview


When I open a project with a package.json in Visual Studio 2015, an npm install is automatically started, and VS is unresponsive until the install is completed.

I would much rather prefer running npm install myself from the command line; how can I stop Visual Studio from doing it?

node.js Solutions


Solution 1 - node.js

Try this:

  • Open Tools -> Options
  • Select Projects and Solutions / External Web Tools
  • Uncheck all four paths
  • Click OK

It doesn't seem that closing the solution, etc., is necessary. NPM and Bower functionality are now disabled in VS but will work fine on the command line (assuming you've globally installed npm, bower, etc.) You may get some error messages in the Output window, but no build errors or warnings.

To restore normal operation, go back to External Web Tools and click "Reset to Defaults" in the lower right.
I haven't tried this with Publish -- you might have to restore defaults to successfully publish, try it if you encounter errors at that point.

Solution 2 - node.js

If you upgrade to Visual Studio 2017 (the free 'Community Edition' is fine) then the VS team have added an option to stop npm running when a project is opened. It's under Tools/Options/Projects and Solutions/Web Package Management/Package Restore. You can disable NPM (and Bower) restores on Project Open and on package.json Save separately.

Note also that for the node.js project types (NTVS) only the automatic package restore behavior is disabled completely in VS2017 at present.

Edit: the above answer also applies to Visual Studio 2019. The menu options are in the same place, although Bower support has been deprecated.

Solution 3 - node.js

Visual Studio 2015 Update 2 fixed this issue! Install Update 2 and you should be good to go.

Direct download: http://go.microsoft.com/fwlink/?LinkId=691129<br> Update 2 Release Notes: https://www.visualstudio.com/news/releasenotes/vs2015-update2-vs

Edit: "fixed" may not be entirely accurate, and it may not be entirely fixed for all users. Maybe we can pin down what everybody's experiencing. To clarify, my experience has been as follows:

  • Prior to Update 2, VS would run 'npm install' every time I opened the .sln, which was very hard to cope with.
  • After Update 2, VS runs 'npm install' in certain scenarios, which is tolerable (in my experience.)

In my experience, post-patch VS will, upon opening the .sln, run 'npm install' if any of the dependencies in package.json are missing from the node_modules folder (or if the folder itself is missing.)

You can't disable the 'npm install', so 'fixed' may not quite be correct - however, it doesn't do it on every launch as before, so I consider it a win. Can folks confirm this is the behavior, or are we experiencing different behaviors?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGeir SagbergView Question on Stackoverflow
Solution 1 - node.jsVan KichlineView Answer on Stackoverflow
Solution 2 - node.jsRich NView Answer on Stackoverflow
Solution 3 - node.jsAshlin AllenView Answer on Stackoverflow