devtron
devtron copied to clipboard
strange requirejs mismtach error
Hi,
I have this very strange issue where when I start electron via npm run start
I get this error in console. see below.
- This error does not break anything as requirejs and application still works fine
- This only happens on my laptop. I tested same source on different machines, this error does not come on other machines.
- If i compile my code and open gui via forcing developer mode to look at console , this error is not there (on same laptop)
- 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.
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}
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.