96

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.

Henry Wilson
  • 3,281
  • 4
  • 31
  • 46
  • 1
    Top Google result for 'visual studio node version' seems like it might do the trick: https://ryanhayes.net/synchronize-node-js-install-version-with-visual-studio-2015/ – Joe Clay May 08 '17 at 14:17
  • 2
    @JoeClay that's for VS2015, things have changed in VS2017. I already tried Google... – Henry Wilson May 08 '17 at 14:23
  • 3
    Ah, I just opened VS, the option has moved... – Joe Clay May 08 '17 at 14:25
  • This https://github.com/aspnet/JavaScriptServices/issues/1686 is also related which means nodejs location must be present in System's Path variable. – Atiq Rahman Jun 14 '18 at 22:28

4 Answers4

163

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

Joe Clay
  • 33,401
  • 4
  • 85
  • 85
  • Not sure what this does, as it hasn't updated anything. – drewid Oct 12 '17 at 05:05
  • 38
    As an alternative that worked for me, just bump the $(PATH) up one, so it supercedes the Web\External directory (assuming node is installed on your environment path) – Leniency Oct 12 '17 at 20:26
  • Mine worked by doing what the answer states. However, this is the second time this issue happened, the first time it was resolved using @Leniency's comment. :) – Imdad Aug 20 '18 at 07:57
  • 1
    "supercedes" or maybe "precedes" – N73k Sep 07 '18 at 15:59
  • @Leniency this worked a treat for me - a node extension (NPM Task Runner by Mads) was using a different (VS) version of node and was failing - thanks! – Michael Harper Oct 19 '18 at 07:42
63

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

Arian Kulp
  • 831
  • 8
  • 31
  • This worked for me. Some package ended up being before '$(PATH)', but when I moved '$(PATH)' up underneath '.\node_modules\.bin' gulp started working again and I got my web app icons back :) – Phil Jul 03 '18 at 12:40
  • Instead of that, you may also see `${VSInstalledExternalTools}`. – General Grievance Apr 03 '23 at 17:22
1

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.

Joseph
  • 5,070
  • 1
  • 25
  • 26
0

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

oatsoda
  • 2,088
  • 2
  • 26
  • 49
JMaFv
  • 41
  • 2