2016-02-28 75 views
7

我尝试使用电子打包和该命令来包装我的应用程序:电子-打包:找不到模块

electron-packager . FooBar --platform=darwin --arch=x64 --version=0.36.9 

(我使用MacOSX的)应用程序的创建,但是当我运行它,我得到一个弹出表示本:

未捕获的异常:

Error: Cannot find module '/Users/myUser/myApp/FooBar-darwin-x64/FooBar.app/Contents/Resources/app/app:/host/menu.html' 
    at Function.Module._resolveFilename (module.js:338:15) 
    at Function.Module._load (module.js:289:25) 
    at Object.<anonymous> (/Users/myUser/myApp/FooBar-darwin-x64/FooBar.app/Contents/Resources/atom.asar/browser/lib/init.js:158:8) 
    at Module._compile (module.js:425:26) 
    at Object.Module._extensions..js (module.js:432:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:313:12) 
    at Function.Module.runMain (module.js:457:10) 
    at startup (node.js:151:18) 
    at node.js:1007:3 
此文件夹中

“/Users/myUser/myApp/FooBar-darwin-x64/FooBar.app/Contents/Resources/app” 有指向html文件“menu.html”的条目,但它se EMS电子无法找到它......

这是我app.js:

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

var mainWindow = null; 


// This method will be called when Electron has done everything 
// initialization and ready for creating browser windows. 
app.on('ready', function() { 

    // Create the browser window. 
    mainWindow = new BrowserWindow({width: 1024, height: 768}); 

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

    mainWindow.openDevTools({detach: true}); 

    // Emitted when the window is closed. 
    mainWindow.on('closed', function() { 
    mainWindow = null; 
    }); 

}); 

你有什么可能是问题的任何想法吗?

谢谢。

回答

10

有两件事情可以尝试:

+0

谢谢,package.json文件中有个错误 – navy1978

+0

我已将'devDependencies'切换到'dependencies',它似乎正在工作! –

0

对我来说,它是如何工作的问题是,模块的依赖性是在“devDependencies”中的package.json上市

将它们移动到“依赖关系”并再次运行npm install解决了问题。