尝试在我的计算机上设置 Electron,为我的 HTML/CSS/JS 项目设置 .exe 文件
我目前正在 Windows 上进行开发并得到了这个:
[3088:0525/235414.074:错误:gpu_process_host.cc(991)] GPU进程启动失败:error_code = 18 [3088:0525/235414.145:错误:gpu_process_host.cc(991)] GPU进程启动失败:error_code = 18 [3088:0525/235414.157:错误:gpu_process_host.cc(991)] GPU进程启动失败:error_code = 18
[3088:0525/235414.161:ERROR:gpu_process_host.cc(991)] GPU process launch failed: error_code=18
[3088:0525/235414.163:ERROR:gpu_process_host.cc(991)] GPU process launch failed: error_code=18
[3088:0525/235414.165:ERROR:gpu_process_host.cc(991)] GPU process launch failed: error_code=18
[3088:0525/235414.171:ERROR:gpu_process_host.cc(991)] GPU process launch failed: error_code=18
[3088:0525/235414.173:ERROR:gpu_process_host.cc(991)] GPU process launch failed: error_code=18
[3088:0525/235414.176:ERROR:gpu_process_host.cc(991)] GPU process launch failed: error_code=18
[3088:0525/235414.176:FATAL:gpu_data_manager_impl_private.cc(448)] GPU process isn't usable. Goodbye.
I'm installing and setting up the framework and was expecting a simple "Hello from Electron with Bulma CSS" displayed on a web page
Current directory is: C:\proyectos\electron\testapp
package.json file:
{
"name": "testapp",
"version": "1.0.0",
"description": "My Electron test app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron ."
},
"author": "Enrique Sifontes",
"license": "BSD-2-Clause",
"devDependencies": {
"electron": "^30.0.8"
}
}
Index.html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<!-- CSP is a PITA ;). Disabled, don't try this at home!-->
<meta http-equiv="Content-Security-Policy" content="">
<!-- include bulma css -->
<link rel="stylesheet" href="bulma/css/bulma.min.css">
<title>My Test App</title>
<script>
window.addEventListener('load', (event) => {
document.querySelector(".hello").textContent = "Hello from Electron with bulma css!";
});
</script>
</head>
<body>
<section class="section">
<div class="container">
<div class="notification is-warning has-text-centered hello">
</div>
</div>
</section>
<script defer src="./index.js"></script>
</body>
</html>
index.js file:
//This is the way to include modules with Node.js, in this case the
//Electron module.
//You can learn more about importing modules by searching
//information about "CommonJS" modules on the internet
const { app, BrowserWindow } = require('electron')
//Create our main windows, here you can set the initial size.
const createWindow = () => {
const win = new BrowserWindow({
width: 800,
height: 600
})
//The HTML file that will be shown, we will create this file in the next section.
win.loadFile('index.html')
}
//This is our starting event, once "Ready", create our main window.
app.whenReady().then(() => {
createWindow()
})
您的问题可能与此类似