node.jsvisual-studionpmtask-runner-explorer

Configure which NPM is used by Visual Studio's Task Runner Explorer?


In a usual Windows command line I see:

C:\Users\me\myProject\UI> node --version
v8.12.0

C:\Users\me\myProject\UI> npm --version
6.11.3

C:\Users\me\myProject\UI> where node
C:\Program Files\nodejs\node.exe

C:\Users\me\myProject\UI> where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\me\AppData\Roaming\npm\npm
C:\Users\me\AppData\Roaming\npm\npm.cmd

Now I am working with Visual Studio Professional 2017: If I open up a (Powershell) terminal via Tools > NuGet Packet Manager > Package Manager console, I see the global installation I favor:

PM> pwd

Path                                                                 
----                                                                 
C:\myProject

PM> Get-Command npm

CommandType     Name                                               Version    Source                                                                                                                                           
-----------     ----                                               -------    ------                                                                                                                                           
Application     npm.cmd                                            0.0.0.0    C:\Program Files\nodejs\npm.cmd   

PM> node --version
v8.12.0
PM> npm --version
6.11.3
PM> Get-Command node

CommandType     Name                                               Version    Source                                                                                                                                           
-----------     ----                                               -------    ------                                                                                                                                           
Application     node.exe                                           8.12.0.0   C:\Program Files\nodejs\node.exe    

However, if I choose Defaults > version within the Task Runner Explorer, I see the following output:

C:\me\myProject> cmd.exe /c npm run version --color=always
> myProject.ui@1.3.7 version C:\me\myProject
> node --version
v10.6.0

That's not the version I want, and neither any of the installations I saw in the command window in the beginning with where npm!

The only way that this is possible is that there is another installation somewhere which is chosen because of the PATH-settings within the Task Runner Explorer. Is that a correct conclusion? I want also the Task Runner Explorer to use the global installation, but how do I do that?


Solution

  • The issue is described at https://github.com/madskristensen/NpmTaskRunner/issues/66 as my colleague just told me. The solution is straight-forward, but only if you know where to look.

    1. Go to Tools > Options > Projects and Solutions > Web Package Management > External Web Tools
    2. In the appearing pop-up window, use the arrow-buttons to move the entry $(PATH) to the 2nd position (it is probably further down in the list)

    Screenshot of Visual Studio Configuration Popup Window