问题描述
出于某种原因,我无法在 Electron 中使用 NodeJS 来要求 fileSystem。这是错误:
Uncaught ReferenceError: require is not defined
package.json:
{
"type": "commonjs","name": "incontroversion","version": "1.0.0","description": "First-order logic solution","main": "Scripts/main.js","scripts": {
"test": "test.js","start": "electron ."
},"repository": {
"type": "git","url": "https://github.com/gabetucker2/incontroversion"
},"keywords": [
"incontroversion"
],"author": "Gabe Tucker","license": "MIT","devDependencies": {
"electron": "^13.1.6"
}
}
preload.js:
const fileSystem = require('fs')//the line of the error
当我将这一行放在 main.js 中时,错误消失了,然后我在使用 fileSystem 而不是说 fileSystem 未定义的那一行出现错误。
我已经坚持了很长一段时间,任何可以帮助我解决这个问题的东西都将不胜感激。我附上了一张我所看到的图片,以防万一。
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)