electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 99 forks source link

`__magic__file__to__help__electron__compile` throwing an error #251

Closed davydany closed 7 years ago

davydany commented 7 years ago

When I load my BrowserWindow with my application, I see

<script src="__magic__file__to__help__electron__compile.js"></script>

getting injected right after the <head> tag. This, however, is throwing an error that says:

Uncaught Error: Cannot find module 'electron-compile/lib/initialize-renderer'

The contents of __magic__file__to__help__electron__compile.js is:

if (window.require) require('electron-compile/lib/initialize-renderer').initializeRendererProcess(false);

My electron.js (which Electron starts) has:

const electron = require('electron');
const app = electron.app;

const LaunchController = require(`${dirname}/api/core/citrus/launch_controller`);

function onReady() {
    var launch_controller = new LaunchController();
    launch_controller.launch();
}

app.on('ready', onReady);

app.on('window-all-closed', function onWindowAllClosed() {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('before-quit', function(event) {

    console.log("Quitting...."); 
});

I have "electron-compile": "^6.4.1", in my package.json in my dependencies object.

I'm lost as to why electron-compile isn't getting setup properly.

davydany commented 7 years ago

Furthermore, I am starting the BrowserWindow with nodeIntegration set to true, as such:

var mainWindow = new BrowserWindow({
            webPreferences: {
                nodeIntegration: true
            },
        });

And, I'm able to call require('electron') without it throwing any errors, as such, in the Developer Tools console:

> require('electron')
>> Object {}

However, calling require('electron-compile/lib/initialize-renderer') throws:

Uncaught Error: Cannot find module 'electron-compile/lib/initialize-renderer'
davydany commented 7 years ago

Figured it out. 😦

... I moved my project files around, and the index.html I was referring to was from the old path, where node_modules was empty.