Update Node Version in Visual Studio 2017

node.jsVisual StudioVisual Studio-2017

node.js Problem Overview


Does anyone know of a sanctioned way to update Node within Visual Studio 2017? I've got Node 6 set up on my development PC but VS2017 appears to come with a bundled copy of Node 5, which means that running npm install on my command line sets up various packages like node-sass with bindings for Node 6, so when I then run gulp tasks from the VS Task Runner things fall over due to the mismatched versions.

I found the VS Node install at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External but I'm a little reluctant to just hack about and replace it. Anyone got any experience of upgrading this? I know I can sync by downgrading the version on my PC but that seems backwards.

node.js Solutions


Solution 1 - node.js

Go to:

> Tools > Options > Projects and Solutions > Web Package Management > External Web Tools

Then you need to add your Node install directory to the top of the list, like so:

screenshot

Solution 2 - node.js

You don't need to add a new Node install directory, Node exists in PATH. Notice how $(PATH) is below the internal path $(DevEnvDir)\Extensions\Microsoft\Web Tools\External.

To use the global PATH environment variable before the internal path, you can just use the arrows at the top-right to change the order.

This is what it looks like when the global PATH is searched before the internal one and therefore will make Visual Studio use your own versions of the tools. enter image description here

Solution 3 - node.js

For me, the issue turned out to be that there was a local node.exe file in the same directory that the csproj file was in, along with a node.exe.config file.

I had a post-build event that would call gulp to do some other work and VS2017 would use the local node.exe file rather than what was listed in my $(PATH) variable. This was an earlier version of node that I didn't want to use, so the solution for me was to either remove the local node.exe so the one listed in $(PATH) would be used or upgrade the local node.exe file if the node.exe.config is really needed.

I just wanted to add this here in case someone else runs into this same issue.

Solution 4 - node.js

It looks as if options in

> Tools > Options > Projects and Solutions > Web Package Management > External Web Tools

have no effect. However it is possible to set the Node version through

> Project > Properties

Project>properties screenshot

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
QuestionHenry WilsonView Question on Stackoverflow
Solution 1 - node.jsJoe ClayView Answer on Stackoverflow
Solution 2 - node.jsEduardo YupanquiView Answer on Stackoverflow
Solution 3 - node.jsJosephView Answer on Stackoverflow
Solution 4 - node.jsJMaFvView Answer on Stackoverflow