Table of Contents
Among the things I love the most in Visual Studio 2015 is the seamless integrations of some of the most advanced community-driven, modern development tools such as Node.js, NPM and Bower. Conversely, among the things I love the least there is the fact that, sadly, the designers chose to ship the product with it’s own version of Node.js and NPM providing them in a internal bundle package instead of installing and using them as external executables. This can be a minor nuisance or a major problem, depending how much you’re using these tools and how often you need to keep them up-to-date – which is something that VS2015 doesn’t allow you to do from within the GUI.
Luckily enough, we can easily update them both with a bit of manual work: let’s see how.
Update NPM only
If we only need to update NPM, we can do it in a matter of seconds.
- Open a Command Prompt with administrative rights.
- Navigate to the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\ folder, which is where Visual Studio 2015 keeps the third-party bundles.
- Once there, execute the following command to see the NPM currently installed version: npm -v
- Right after that, execute the following command to update NPM to the latest available version: npm install npm -g (or npm install npm@latest -g if the former doesn’t work, as explained here).
Update NodeJS and NPM
Unfortunately, we can’t do the same with Node.js because the update via NPM – although supported by all the linux distributions – doesn’t work for the Windows port. If we want to update it too, we need to install the latest version manually using the appropriate .msi package and then instruct Visual Studio 2015 to use it instead of the bundled one.
- Download the Node.js latest version from the official project page (currently it’s 6.3.1).
- Install it and take a note of the installation path, such as C:\Program Files\nodejs (the default one).
- Once done, open a Command Prompt with administrative priviledges, navigate to the installation folder and update NPM to the latest version by typing npm install npm -g .
Telling VS2015 to use the new version
- Launch Visual Studio 2015.
- From the main menu, go to Tools > Options > Projects & Solutions > External Web Tools.
- Click to the “Add new” icon on the top-right of the screen and add the Node.js installation path, then use the arrow icons to move it to the top of the list.
If you do it correctly you should end with a result similar to the following screenshot:
From now on, Visual Studio 2015 will use the updated versions of Node.js and NPM instead of the bundled ones.
If you’re unable to update NPM due to some console errors such as the following one:
npm ERR! enoent ENOENT: no such file or directory
you could try these workarounds:
- Try to clean the NPM cache using npm cache clean and try again.
- Specify the desired version (latest) using the npm install npm@latest -g revised command (thanks to Mark Olbert for sharing this).
That’s it for now: happy coding!