How can I disable NPM package restore in Visual Studio 2015?
Solution 1
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 2
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 3
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
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?
Related videos on Youtube
Comments
-
Geir Sagberg about 4 years
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?
-
Geir Sagberg almost 9 yearsWhile i do get some errors in the output, e.g. Task Runner Explorer doesn't find Gulp etc., I guess this is expected. This certainly does the trick, thanks :)
-
Sean Anderson over 8 yearsIt's pretty ridiculous that you can't disable this option. :(
-
cchamberlain over 8 years+1 VS is slow enough without git and npm integration. Better to use VS Code / Sublime / Webstorm for JS related projects.
-
Alessandro Cuttin about 8 yearsWhile this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
-
Ashlin Allen about 8 yearsThe link doesn't contain the answer, it's only there for the software update download. I changed the link to link directly to the download, instead of the update notes. Is that acceptable?
-
npjohns about 8 yearsI wouldn't call it fixed, they made the screen less likely to lock or crash, but if you manually deal with npm, it will get in fights with the vs auto restore, and there still isn't an option to disable it afaik.
-
Jamie McCrindle about 8 yearsI have Visual Studio 2015 Update 2 and it still tries to run npm install and gulp. I'm not sure if this fixes the problem.
-
Ashlin Allen about 8 yearsI've edited my answer, are you also seeing it run 'npm install' in the specific scenario I mention, or is it running other times? As for Gulp, I'll try to dig into that... my current setup is using Webpack and VS only runs Webpack if I have Task Runner Explorer configured to do so. VS is running Gulp even without TRE being configured to run it?
-
TetraDev about 8 yearsThere has to be a way to disable this. Its really a productivity killer because I already created my own script that does NPM install on solution launch, so now it's happening twice. Who knows how to customize the VS2015 code via extensions?
-
rsenna over 6 yearsUsing VS Community 2017 15.5.6. This actually works, but I did have to restart Visual Studio in order to make it stop restoring npm packages.
-
amartin1911 about 4 yearsIs there a permanent solution? I've applied this, then upgraded VS2019 and boom, NPM enabled again
-
amartin1911 about 4 yearsIs there a permanent solution? I've applied this, then upgraded VS2019 and boom, NPM enabled again