Search code examples
requirejsvisual-studio-2017visual-studio-cordova

Cordova build for Windows-x86/x64 with Visual Studio 2017 crashing if requirejs is included


I've created a blank Cordova project which compiles just fine to Win x64/x86 in Visual Studio 2017.

Then installed RequireJS 2.3.3 via bower, copied into www/scripts folder with gulp. Verified if it's there.

After this I called the index.js file with requirejs from index.html.

<script src="scripts/require.js" data-main="scripts/index.js"></script>

If I compile the project for Windows 10 (either Cordova 6/7) the app window pops up, then solution crashes with no error message. Does the same failure even by including it without the data-main.
If I compile the project for Android all works fine.

If somebody have a solution for this, would be much appreciated. Does Windows requires additional options to use require.js?

Thanks!


Solution

  • For those who are facing the same issue I had in my question section:

    1. Go to your solution folder and delete the platform what is making you trouble, in my case I had trouble with Windows, so I deleted the platforms/windows folder, restarted Visual Studio 2017.

    2. Reopen the project. Now go to your config.xml and edit it by View Code (left click) and go to the end of the file and make sure you have the following:

      enter image description here

    not sure about the iOS since I haven't tested it yet.
    3. selected the platform you want, VS will regenerate the entire platform folder inside "platforms" and problem solved.