Jaa


Unable to build a simple Cordova app in Visual Studio? Here’s a possible fix…

It is not so often these days that support cases have a quick solution. With the wealth of forums and other channels for peer assistance, most straightforward issues get fixed before people call us. So it is a pleasant change when something turns out to be quickly fixable.

In this case, the customer was using the Apache Cordova tooling for Visual Studio. We’d confirmed they were using the latest version of this, which at the time was Update 6.

Even a simple app created from the provided template would not build.

The build log was showing this:

1>         npm ERR! code EJSONPARSE
1>         npm ERR! Failed to parse json
1>         npm ERR! Unexpected token '\u0000' at 1:1
1>         npm ERR!          npm ERR! ^

 

With quick input from the our team in Redmond that work on this it was clear the customer’s NPM cache had somehow got corrupted.

Suggestion was to clear the cache, by shutting down Visual Studio and deleting the contents of “C:\Users\[USERNAME]\AppData\Roaming\npm-cache”.

Happily, this fixed it.

HTH

Doug

Comments

  • Anonymous
    February 16, 2016
    I gave up doing it through visual studio when building my cordova/ionic app. Instead just compiled it using the CLI which by far works consistently better.I remember there was/is a bug during the build of the cordova app where it would add a space character to the config.xml file thereby failing the build process.
  • Anonymous
    January 11, 2017
    I don't have an AppData folder but I am getting an error that suggests I need to clear my cache.I have updated the path to JDK to be 1.8, but Visual Studio is still looking for JDK 1.7 on app build
    • Anonymous
      January 11, 2017
      so the question is, how do I clear my cache if I do not have an AppData folder
      • Anonymous
        January 11, 2017
        Hi YvonneA better way now is probably to go into Tools->Option in Visual Studio, click on the "Tools for Apache Cordova" node and then click on "Clear Cache" in the right. AppData is a hidden folder by default. You need to select "Show hidden items" on the View tab in Explorer.HTHDoug