TACOBOT

The Official Blog for Visual Studio
Tools for Apache Cordova

By our developers, for developers.

New WebTools Preview update NPM version

The ASP.NET team recently released Microsoft ASP.NET Web Tools Preview 1 RC2 which include tooling changes of interest to developers working with Cordova or ASP.NET. Specifically, they’ve updated the version of Node and NPM used by Visual Studio 2015 for NPM package restore and the Task Runner Explorer.

Prior to this update, newer versions of NPM cause some interoperability problems between the Visual Studio Package Manager and the command line, that could affect your Cordova development workflow.

Note: if you don’t want to install the new preview release, you can still configure Visual Studio to use other version of node/npm as described here, however it has not been optimized for NPM 3.x.

Here’s a summary of the two major issues fixed by this preview release, which I think are of interest to Visual Studio TACO developers.

Extraneous Dependencies

Recent versions of node install recent versions of npm, which use a flat folder (not deeply nested) structure for node_modules that was introduced in npm 3. However, when the same project was opened in Visual Studio TACO it would try to restore using an older sandboxed version of npm. This caused Visual Studio to incorrectly show dependencies as “extraneous”.

extraneous

Task Runner failed to load Gulp tasks

Another common problem you may have seen is an error similar to the following, in the Output Window under the Task runner explorer logs:

Failed to run "C:\code\TacoApp\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
Error: Missing binding C:\code\TacoApp\node_modules\node-sass\vendor\win32-ia32-11\binding.node
Node Sass could not find a binding for your current environment: Windows 32-bit with Node 0.10.x
Found bindings for the following environments:
  - Windows 64-bit with Node.js 4.x
This usually happens because your environment has changed since running npm install.

This is caused when node_modules were restored from the command line using a different version of Node than what Visual Studio uses. With this update, Visual Studio is using a much newer version of Node and NPM, which will make this error message much less common.

Note: You may still run into this issue in the future. The easiest way to fix it is removing the node_modules folder, and let Visual Studio restore them again: Open the solution explorer, find the Dependencies node, right-click and select Restore Packages.

Microsoft ASP.NET Web Tools Preview 1 RC2

You can get the new version here: Microsoft ASP.NET Web Tools Preview 1 RC2

If you still find any issue restoring packages, or using the Task Runner Explorer, please let us know.

Ricardo Minguez (aka Rido)
Program Manager | Tools for Apache Cordova (TACO)
rmpablos -at- microsoft -dot- com | @ridomin