I have a typescript project that requires npm 3+. I've install it to C:\Program Files\nodesjs, and I set my system environment variables to point there.
In visual studio 2017 though, when I set the external tools location, it still doesn't pick up npm version 3+.
For your Node installation folder, I'm assuming you meant:
C:\Program Files\nodejs NOT
C:\Program Files\nodesjs
Also, you're testing the npm version from the Package Manager Console. I'm not sure that respects your external tools configuration (but rather a Powershell Profile) so the result there may not change.
Instead, with your project open, you should be able to right-click on the npm node under Dependencies in Solution Explorer and select Restore Packages. In your Output window (Bower/npm), you should see the npm install
command being executed from your machine-wide Node installation:
"C:\Program Files\nodejs\npm.CMD" install
The way you add an extra path to the external tools seems correct.
Are you sure you have the correct version there ?
(On my installation the built-in nodejs version was 5.4.1 and npm verison 3.3.4)
To be sure, for me the best way to figure out which npm installation Visual Studio 2017 was using is this (taken from How to get the npm global path prefix) :
PM> npm config get prefix
And if all else fails, you can always update the built-in npm too.
Just navigate to your web external path (probably C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External) and :
pm> npm install npm@latest
The external web tools configuration is only used when building. The PATH
variable is (re-)set using the $(ExternalToolsPath)
parameter by one of the build tasks which is: a semi-colon concatenated value of the external web tools list.
Since you are running the command in the PowerShell Console window, your external web tools configuration is not used.
My best assumption is that you've got multiple directories in your PATH
environment variable that has the npm
executable. The latest directory will always win. If this is the case, either remove the duplicate ones or make sure that the directory where your latest version of npm
is added last. You can do this from the system properties or from the Nuget profile used by the PowerShell Console window.
To check your PATH
variable in PowerShell use:
Write-Host $ENV:Path
To list the possible locations of the npm executable from PowerShell use:
cmd /c where npm
I had a similar issue when trying to use Task Runner Explorer with webpack. My issue was that my webpack.config.js file was not in the root of my project (it was in my scripts folder). Moving it to the root did the trick for me.