title: Simple RequireJS, AngularJS, Electron App, Dependencies not Executing
body: <p>I am writing my first Electron/Angular/RequireJS single page desktop app.  I started with the <a href="https://github.com/szwacz/electron-boilerplate" rel="nofollow noreferrer">electron-boilerplate</a> and it works great.  However, I need to add AngularJs to the equation--the boiler plate already uses RequireJS.  I've tried a number of solutions but I either get errors, or dependencies not being executed.  So I tried to implement the simple example from a previous stack overflow question, "<a href="https://stackoverflow.com/questions/19575410/simple-requirejs-with-angularjs-angular-is-not-defined">Simple requireJS with angularJS - angular is not defined</a>".  However, what I see is that the files are being parsed, but it never executes the code inside.  It's almost like one or more of the dependencies are not met so they do not execute.  My files are as follows--I have added some logging so I can easily see the execution path.</p>
  
  <p><strong>app.html</strong> -- The starting point that includes RequireJS.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Electron Boilerplate&lt;/title&gt;
  &lt;/head&gt;
  &lt;body ng-app="ReqApp" ng-controller="GreetCtrl"&gt;
  
      &lt;h1&gt;{{greeting}}!&lt;/h1&gt;
      &lt;script data-main="require_config" src="vendor/require.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>require_config.js</strong> -- This contains the RequireJS configuration.</p>
  
  <pre><code>console.log("REQUIRE_CONFIG.JS-------------"+requirejs.version);    
  requirejs.config({
      // alias libraries paths
    paths: {
      'domReady':      './vendor/requirejs-domready',
      'angular':       './node_modules/angular/angular',
      'GreetCtrl':     './js/GreetCtrl',
      'app':           './js/app'
    },
    // angular does not support AMD out of the box, put it in a shim
    shim: { 'angular': { exports: 'angular' }
    },
    // kick start application
    deps: ['./bootstrap']
  });
  </code></pre>
  
  <p><strong>bootstrap.js</strong> -- File from the RequireJS <code>deps</code> to manually bootstrap AngularJS.</p>
  
  <pre><code>console.log("BOOTSTRAP.JS1-------------");
  define([
      'require',
      'angular',
      'app'
  ], function (require, ng, app) {
      'use strict';
  
      console.log("BOOTSTRAP.JS2+++++++++++++");
      require(['domReady!'], function (document) {
          console.log("BOOTSTRAP.JS+++++++++++++");
          ng.bootstrap(document, ['ReqApp']);
      });
  });
  </code></pre>
  
  <p><strong>./js/app.js</strong> -- This initializes the AngularJS module for the application.</p>
  
  <pre><code>console.log("APP.JS-------------"+requirejs.version);
  define([
    'angular',
    'GreetCtrl'
  ], function (ng) {
    'use strict';
  
    console.log("APP.JS+++++++++++++");
    return ng.module('ReqApp', [ 'ReqApp.GreetCtrl' ]);
  });
  </code></pre>
  
  <p><strong>./js/GreetCtrl.js</strong></p>
  
  <pre><code>console.log("GREETCTRL.JS1-------------");
  define(['angular'], function(angular) {
      console.log("GREETCTRL.JS1+++++++++++++");
      angular.module( 'ReqApp.GreetCtrl', [])
      .controller( 'GreetCtrl', function GreetCtrl ($scope) {
           $scope.greeting = "Hello World";
      });
  });
  </code></pre>
  
  <p>The console output from running this example is:</p>
  
  <pre><code>[16982:0917/115914:ERROR:browser_main_loop.cc(173)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
  [17010:0917/115915:INFO:renderer_main.cc(200)] Renderer process started
  [17014:0917/115915:INFO:renderer_main.cc(200)] Renderer process started
  [16982:0917/115915:ERROR:browser_gpu_channel_host_factory.cc(146)] Failed to create channel.
  [16982:0917/115915:INFO:CONSOLE(43)] "REQUIRE_CONFIG.JS-------------2.1.20", source: file:///home/swdev/projects/build/require_config.js (43)
  [16982:0917/115915:INFO:CONSOLE(8)] "BOOTSTRAP.JS1-------------", source: file:///home/swdev/projects/build/bootstrap.js (8)
  </code></pre>
  
  <p>The pages output is:</p>
  
  <pre><code>{{greeting}}!
  </code></pre>
  
  <p>As you can see from the output it seems that only the require_config.js and bootstrap.js files are parsed but the code within the define is not executed.  My questions are:</p>
  
  <ol>
  <li>Why is the bootstrap.js function never called?</li>
  <li>Why are the app.js and GreetCtrl.js files not even parsed?</li>
  <li>Since Electron uses node I have to use <code>requirejs</code>, do I need to remove my use of <code>require</code> from bootstrap.js and replace it with <code>requirejs</code> as well?  NOTE: I have tested changing this but it did nothing for my problem.</li>
  <li>I did notice that the <a href="https://stackoverflow.com/questions/19575410/simple-requirejs-with-angularjs-angular-is-not-defined">stack overflow example</a> that I followed defines <code>ng-app="ReqApp"</code> within the HTML body definition.  My limited understanding is that this should be removed since we are manually bootstrapping AngularJS.  What is the correct approach for my use case (Election(node)/RequireJS/AngularJS?  NOTE: I have tested by removing the definition from the body definition and it did nothing for my problem.</li>
  </ol>
  
  <p>I have spent a few days attempting to solve this problem, so any help would be <strong>much</strong> appreciated!</p>
  
  <hr>
  
  <p>Additional Attempts:
  Played some more to simplify part of the problem.  I can't seem to get RequireJS to execute or parse some dependencies.  My simplification is:</p>
  
  <p><strong>./app.js</strong></p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Electron Boilerplate&lt;/title&gt;
  &lt;/head&gt;
  &lt;body &gt;
      &lt;script data-main="require_config" src="vendor/require.js"&gt;&lt;/script&gt;
      &lt;h1&gt;Hello World!&lt;/h1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>./require_config.js</strong></p>
  
  <pre><code>console.log("REQUIRE_CONFIG.JS-------------"+requirejs.version);
  requirejs.config({
      paths: {
      'app': './js/app'
    },
    // kick start application
    deps: ['./bootstrap']
  });
  </code></pre>
  
  <p><strong>./bootstrap.js</strong></p>
  
  <pre><code>console.log("BOOTSTRAP.JS1-------------");
  define( ['app'], function (app) {
      'use strict';
      console.log("BOOTSTRAP.JS2+++++++++++++");
  });
  </code></pre>
  
  <p><strong>./js/app.js</strong></p>
  
  <pre><code>console.log("APP.JS-------------");
  define([], function () {
    'use strict';
    console.log("APP.JS+++++++++++++");
  });
  </code></pre>
  
  <p>The resulting output is still the same as my original output above.  boostrap.js and require_config.js are processed.  The bootstrap.js define/function is never called and app.js is never parsed.</p>