Update Node.js integrated with Visual Studio 2015
Visual Studio 2015 comes with several useful third-party tools installed and integrated with IDE. Those include Node.js, npm, git client, etc. Task Runner Explore window, that was a separate extension in VS2013, is now part of the default installation and allows to run task defined for Gulp or Grunt.
What I have noticed stumbling into a problem recently, is that those tools (so far) didn’t get any updates – there’s nothing in Extensions and Updates, Windows Update or Notifications panel in Visual Studio related to those tools that would suggest that update is needed. Still, the world goes on. Node.js has recently released it’s 4.0.0 version (a big jump in numeration from 0.12.7 released before), but the image I currently have in \Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\node\node.exe is at version 0.10.31, so this executable is currently over 1 year old.
I noticed the problem when I tried to run a Gulp task from Task Runner Explorer window that required gulp-autoprefixer component. It officially requires Node.js version >= 0.12.0, but broke with a less clear error like:
ReferenceError: Promise is not defined
at LazyResult.async (...\node_modules\gulp-autoprefixer\node_modules\postcss\lib\lazy-result.js:152:31)
at LazyResult.then (...\node_modules\gulp-autoprefixer\node_modules\postcss\lib\lazy-result.js:75:21)
Knowing that promises are currently a new part of ECMAScript 2015 standard, I updated node.js to the current version and it solved the problem – I could successfuly run the problematic Gulp task from Command Prompt. However, Task Runner Explorer still had the same problem.
Using Process Explorer tool from Sysinternals package I checked that the node.exe that is executed by VS 2015 is loaded from Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\node\node.exe and not c:\Program Files\nodejs\node.exe where the current version is installed.
Fortunately, it’s very easy to change the path where Visual Studio looks for node’s executable. This can be done by going to Debug->Options->Projects and Solutions->External Web Tools, adding path to the most current node.js installation (typically c:\Program Files\nodejs and moving it to the top of this priority list.
PS Depending on the order of commands in the Gulp file, I also bumped into the error shown below that was also resolved by update. If you are looking for a solution to this one, make sure that your Node, npm, or node modules are up to date:
Error: no writecb in Transform class
at afterTransform (...\node_modules\gulp-less\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:95:33)
at TransformState.afterTransform (...\node_modules\gulp-less\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:79:12)
Thanks a lot! You save my day 😉
This helped me a lot. Thank you!
I would suggest “uping” the priority on your PATH variable (that is if you have node in your PATH) so it is above the Microsoft reference rather than “adding” another reference.
Guys, be sure to keep an eye on this blog. It has updated versions of VS tools directly from Microsoft, and these may fix some or all of your NPM issues.
It’ll help if I put the actual URL in, won’t it? 😀 http://microsoft.github.io/vstacoblog/