devtron icon indicating copy to clipboard operation
devtron copied to clipboard

strange requirejs mismtach error

Open mafar opened this issue 8 years ago • 2 comments

Hi, I have this very strange issue where when I start electron via npm run start I get this error in console. see below.

  1. This error does not break anything as requirejs and application still works fine
  2. This only happens on my laptop. I tested same source on different machines, this error does not come on other machines.
  3. If i compile my code and open gui via forcing developer mode to look at console , this error is not there (on same laptop)
  4. I have tried clearing , caches, uninstalling and installing node.js and node modules again from scratch but it is still there.

my HTML :

  <body >
 
    <script>
      if (window && window.process && window.process.versions['electron']) {
        // is running inside electron not in web-browser
        // 
        // http://electron.atom.io/docs/faq/#i-can-not-use-jqueryrequirejsmeteorangularjs-in-electron
        // move window.module, window.require inserted in DOM becuase of electron-node integration
        // 
        window.nodeRequire = window.require;
        window.nodeExports = window.exports;
        window.nodeModule = window.module;
        delete window.exports;
        delete window.module;
      }
      window.require = {
        waitSeconds: 0,
        urlArgs: 'bust=' + (new Date()).getTime()
      };
    </script>
    <script src="./js/requirejs/require.js"></script>
 
  </body>

ERROR:

require.js:168 Uncaught Error: Mismatched anonymous define() module: function () {
  var COMPILED = !0, goog = goog || {};
goog.global = this;
goog.isDef = function(a) {
  return void 0 !== a;
};
goog.exportPath_ = function(a, b, c) {
  a = a.split(".");
  c = c || goog.global;
  a[0] in c || !c.execScript || c.execScript("var " + a[0]);
  for (var d;a.length && (d = a.shift());) {
    !a.length && goog.isDef(b) ? c[d] = b : c = c[d] ? c[d] : c[d] = {};
  }
};
goog.define = function(a, b) {
  var c = b;
  COMPILED || (goog.global.CLOSURE_UNCOMPILED_DEFINES && Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES, a) ? c = goog.global.CLOSURE_UNCOMPILED_DEFINES[a] : goog.global.CLOSURE_DEFINES && Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES, a) && (c = goog.global.CLOSURE_DEFINES[a]));
  goog.exportPath_(a, c);
};
goog.DEBUG = !0;
goog.LOCALE = "en";
goog.TRUSTED_SITE = !0;
goog.STRICT_MODE_COMPATIBLE = !1;
goog.DISALLOW_TEST_ONLY_CODE = COMPILED && !goog.DEBUG;
goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = !1;
goog.provide = function(a) {
  if (goog.isInModuleLoader_()) {
    throw Error("goog.provide can not be used within a goog.module.");
  }
  if (!COMPILED && goog.isProvided_(a)) {
    throw Error('Namespace "' + a + '" already declared.');
  }
  goog.constructNamespace_(a);
};

Error is very long so i am just pasting few lines above.

mafar avatar Dec 13 '16 14:12 mafar

I tried this solution as well but problem is sill there index.js

  mainWindow = new BrowserWindow({
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  });

preload.js

window.__devtron = {require: require, process: process}

mafar avatar Dec 14 '16 04:12 mafar

To add efficacy of this bug, I will add that I'm getting the exact same error. When using devtron in any electron window that also uses requirejs, it causes requirejs to throw this error.

ljcrapo avatar Jul 05 '17 20:07 ljcrapo