电子应用在定义/需要各种javascript应用程序时失败

我正在尝试使用电子将网页捆绑到一个应用程序。

我可以做样品应用程序的罚款,但我的网页使用jQuery和各种依赖jQuery的库来操作。 本身,该网站在Web浏览器中正常工作,但通过电子启动时,我会从库的定义/导出语句中获得各种javascript错误。

我的电子应用程序的结构如下:

main.js package.json app index.html js/app.js js/lib/jquery.js js/lib/library1.js ... 

应用程序包含所有依赖于包含库的自定义代码,索引如下所示:

 <!DOCTYPE html> <html lang="en"> <head> <title>[TITLE]</title> <link rel="stylesheet" href="css/main.css"> </head> <body> <script src="js/lib/jquery.js"></script> <script src="js/lib/library1.js"></script> <script src="js/app.js"></script> </body> </html> 

Package.json看起来像这样:

 { "name" : "LosYork", "version" : "0.1.0", "main" : "main.js" } 

main.js是电子文件,它只是复制快速入门的代码:

 const electron = require('electron') // Module to control application life. const app = electron.app // Module to create native browser window. const BrowserWindow = electron.BrowserWindow // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow function createWindow () { // Create the browser window. mainWindow = new BrowserWindow({width: 800, height: 600}) // and load the index.html of the app. mainWindow.loadURL('file://' + __dirname + '/app/index.html') // Open the DevTools. mainWindow.webContents.openDevTools(); // 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 }) } // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', createWindow) // 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() } }) app.on('activate', function () { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (mainWindow === null) { createWindow() } }) // In this file you can include the rest of your app's specific main process // code. You can also put them in separate files and require them here. 

只更改索引文件的path(/app/index.html)。

我知道我并没有完全掌握使用节点的“require”的过程,而且在快速入门中我们看到索引文件中有一个require语句,以及main.js底部的代码注释在这里也可以要求事物,但是如果我尝试将脚本作为require语句而不是仅仅作为等等,我注意到没有区别。

例如,我将从依赖于jQuery的库中看到一个典型的错误,例如:

jQuery is not defined

在线:

 (function(factory) { 'use strict'; if (typeof define === 'function' && define.amd) { define(['jquery'], factory); } else if (typeof exports !== 'undefined') { module.exports = factory(require('jquery')); } else { factory(jQuery); //ERROR OCCURS HERE } }(function($) { ... })); 

如何将这些库包含在电子文件中,以便它们在应用程序中可用,就像在我的正常Web应用程序中一样?