我已经创建了一个角10项目使用角-CLI。在此之后,我已经安装了电子,并完成了以下操作:将src/index.html基础更改为本地安装的电子。但是当运行我的代码时,它会显示出一些错误。
如何纠正此错误?
这是我的main.js文件
const { app, BrowserWindow } = require('electron')
let win;
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 600,
height: 670,
icon: `file://${__dirname}/dist/assets/logo.png`
})
win.loadURL(`file://${__dirname}/dist/index.html`)
// uncomment below to open the DevTools.
// win.webContents.openDevTools()
// Event when the window is closed.
win.on('closed', function () {
win = null
})
}
// Create window on electron intialization
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS specific close process
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// macOS specific close process
if (win === null) {
createWindow()
}
})这是我的package.json文件
{
"name": "angu",
"version": "0.0.0",
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron":"electron .",
"electron-build": "ng build --prod && npm run electron ."
},这是我的index.html文件
<base href="./">

发布于 2020-09-25 10:38:09
在过去的两天里,我也被困在这个问题上。经过大量的搜索和对电子的了解。我解决了这个问题,以及那个问题之后的问题。
用于解决Please verify that the package.json has a valid "main" entery问题
您需要用main文件的路径更新package.json文件中的main.js。最有可能的是
"main": "src/main.js",
当您执行此更改时,运行命令npm run electron-build。它将创建您的电子应用程序的构建,但不会在页面上显示任何内容,如果您看到控制台,这里您将看到1错误Not allowed to load local resource:。要解决这个错误,您应该访问以下链接
https://stackoverflow.com/questions/63450655
复制相似问题