FIXED: Error Building Cordova in Visual Studio

So, I am trying to build an Apache Cordova project in Visual Studio 2015 and it is not playing nice. I see quite a few errors related to npm, so I’m going to blog it out.


First the errors. Here is a sample of them:

FindPackagesById: System.Console; File: RUNMDAINSTALL 

Error ENOENT, no such file or directory ‘C:\Users{name}\AppData\Roaming\npm\node_modules\vs-tac\node_modules\edge\src\CoreCLREmbedding\project.lock.json’; File: RUNMDAINSTALL 

BLD401 Error : BLD00401 : Could not find module ‘C:\Users{name}\AppData\Roaming\npm\node_modules\vs-tac\app.js’. Please Go to Tools –> Options –> Tools for Apache Cordova –> Cordova Tools –> Clear Cordova Cache and try building again. 


There is no way that I can say what the real solution is because it is dependent on versions of node, npm and VS Cordova Tools, but if you have a vs-tac issue, try:

  1. Clearing your Cordova Cache:
    in Visual Studio Go to Tools > Options > Tools for Apache Cordova > Cordova Tools > Clear Cordova Cache
  2. Copy vs-tac from your VS install to your profile:
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\Packages\vs-tac to C:\Users\{name}\AppData\Roaming\npm\node_modules
  3. Manually install any missing node dependencies globally:
    >npm install {dependency name} -g

My Journey to Solution

First I tried the fix in the last error above: Options –> Tools for Apache Cordova –> Cordova Tools –> Clear Cordova Cache and try building again. This didn’t work, but I learned where the Cordova config is so that’s a plus.

Next I tried to manually install Cordova from npm and got this lovely error:

npm ERR! Failed to parse json
npm ERR! No data, empty input at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: C:\Users\cbryant\AppData\Roaming\npm-cache\xtend\4.0.1\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.

So, I went down the rabbit hole and focused on fixing this as it may be part of my original problem.

npm cache clean
npm install cordova -g

This worked, I was able to install Cordova manually, but had no effect on my original problem and this Yak still has a lot of hair to shave.

So the issue is linked to some npm package named vs-tac. A little searching and I discovered that it may already be installed here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\Packages\vs-tac.

Let’s try to install it to my profile to see if that fixes the issue.

npm install “C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\packages\vs-tac” -g

OK, I’m seeing some of the same errors that I see in Visual Studio. I discover that some of the errors are because of a bad Nuget source, so I remove the source and land on this error:

npm ERR! Failed at the edge@5.0.0 install script ‘node tools/install.js’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the edge package,
npm ERR! not with npm itself.

How do you check the latest version of node.js and npm? I asked Google the same questions:

node -v
npm -v

I am running node 5 and the current stable is 4, not sure if that is an issue. Going to run the latest msi for v5 to see if it does something. By the way you can find all of the node installers here:

Upgrading npm was a little different. I have npm installed in my node install, C:\Program Files\nodejs\npm.cmd. To upgrade I found this command

npm install npm -g

This installs the latest npm to my profile, but I assume running npm defaults to the one in the node install (based on a couple posts I read). So, I deleted the one in the node install and everything is upgraded and working (By the way, I had to restart my administrator command prompt to get npm to work at the new location), but I still get the last error above (still shaving this yak).

So, I have to read logs :(, C:\WINDOWS\system32\npm-debug.log. After a painful read, I give up on the command line and manually copy vs-tac from C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\Packages\vs-tac to C:\Users{name}\AppData\Roaming\npm\node_modules. When I build again all of the errors are gone except one:

BLD401 Error : BLD00401 : Could not find module ‘elementtree’. Please Go to Tools –> Options –> Tools for Apache Cordova –> Cordova Tools –> Clear Cordova Cache and try building again. StationHouse.Mobile

I clear the Cordova Cache and it deletes the vs-tac in my profile. I add vs-tac back and build again with the same error. I go to check the package.json in the vs-tac folder and notice that node_modules doesn’t exists so I run npm install inside this directory to install the packages, but edge still won’t install.

I manually install edge:

npm install edge@5.0.0 -g

When I rebuild it succeeds, that yak has a nice crew cut.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s