Skip to content

Error: Cannot find module ... app.asar/index.js #303

Description

@santekotturi

Successfully built my angular1 app as an electron app. I can run it using electron-prebuilt, however, when I launch the installed dmg, the app fails immediately.

Image contains error message:

image

my dev-level package.json:

{
    "name": "activity-frontend",
    "version": "1.1.1",
    "author": "Sante Kotturi",
    "description": "activity-frontend: An Ionic project",
    "dependencies": {
        "gulp": "^3.5.6",
        "gulp-concat": "^2.2.0",
        "gulp-minify-css": "^0.3.0",
        "gulp-rename": "^1.2.0",
        "gulp-sass": "^2.0.4"
    },
    "devDependencies": {
        "bower": "^1.3.3",
        "electron-builder": "^3.5.0",
        "electron-prebuilt": "^0.37.5",
        "gulp-util": "^2.2.14",
        "shelljs": "^0.3.0"
    },
    "scripts": {
        "electron": "electron www",
        "postinstall": "install-app-deps",
        "pack": "build",
        "dist": "build"
    },
    "build": {
        "osx": {
            "contents": [
                {
                    "x": 410,
                    "y": 220,
                    "type": "link",
                    "path": "/Applications"
                },
                {
                    "x": 130,
                    "y": 220,
                    "type": "file"
                }
            ]
        }
    }
}

my app-level package.json which specifies a main.js:

{
  "name"    : "activity-uploader",
  "version" : "0.0.1",
  "main"    : "main.js"
}

my main.js just in case it helps: [EDIT with correct main.js]

var app = require('app');  // Module to control application life.
var BrowserWindow = require('browser-window');  // Module to create native browser window.

// Report crashes to our server.
require('crash-reporter').start();

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is GCed.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform != 'darwin') {
    app.quit();
  }
});

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 700});

  // and load the index.html of the app.
  mainWindow.loadURL('file://' + __dirname + '/index.html');

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});

I launched Mac Finder > my app > Contents > Resources
to see if app.asar was an inspectable but its a binary file:
app.asar: application/octet-stream; charset=binary

Any help or pointing in the right directions of resources is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions