gpt4 book ai didi

javascript - 要求 Electron 中的视点卡住 Electron 实例

转载 作者:行者123 更新时间:2023-12-03 12:28:39 26 4
gpt4 key购买 nike

当index.html中需要node-opcua时,Electron冻结,并且名为Electron Helper的进程占用了100%的CPU。

我在macOS 10.14.2上遇到了问题,但是有一位 friend 在Windows 10中进行了测试,并且可以正常工作。

从package.json

"devDependencies": {
"electron": "^4.0.4"
},
"dependencies": {
"node-opcua": "^0.5.6"
}

Main.js
const { app, BrowserWindow } = require('electron')

function createWindow () {
// Create the browser window.
win = new BrowserWindow({ width: 800, height: 600 })

// and load the index.html of the app.
win.loadFile('index.html')

win.webContents.openDevTools()
}

app.on('ready', createWindow)

Index.html
<script>
// Does not work
const opcua = require('node-opcua')
console.log(opcua)

// Works
// const fs = require('fs')
// console.log(fs)
</script>

运行简单代码时,应仅在控制台中打印opcua对象。但是完整的 Electron 化过程冻结了。

最佳答案

通过将node-opcua更新为2.1.9并将 Electron 更新为6.0.11来解决此问题

关于javascript - 要求 Electron 中的视点卡住 Electron 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54516256/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com