【发布时间】:2021-08-01 09:11:43
【问题描述】:
您好一直在尝试提取并重新打包 app.asar 以更新包内的文件:
await asar.extractAll(path.join(__dirname, './app.asar'),path.join(__dirname, './destfolder'));
然后更改destfolder中的一些文件
await asar.createPackage(path.join(__dirname, './destfolder'),path.join(__dirname, './app.asar'));
但我一直收到此错误:
ReferenceError: BigInt is not defined
at new Filesystem (C:\Users\Path\to\project\node_modules\asar\lib\filesystem.js:17:5)
at Object.module.exports.readFilesystemSync (C:\Users\Path\to\project\node_modules\asar\lib\disk.js:85:24)
at Object.module.exports.extractAll (C:\Users\Path\to\project\node_modules\asar\lib\asar.js:170:27)
at Request._callback (C:\Users\Path\to\project\server.js:221:26)
at Request.init.self.callback (C:\Users\Path\to\project\node_modules\request\request.js:185:22)
at Request.emit (events.js:182:13)
at Request.<anonymous> (C:\Users\Path\to\project\node_modules\request\request.js:1154:10)
at Request.emit (events.js:182:13)
at IncomingMessage.<anonymous> (C:\Users\Path\to\project\node_modules\request\request.js:1076:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1090:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
平台:Windows x64 节点版本:v14.15.1
我不知道这是否是一个错误,但我已经卡在这个问题上大约 2 天了,但没有找到解决方案 我在这里创建了一个问题:https://github.com/electron/asar/issues/217 感谢您的努力,请不要犹豫询问任何信息
更新
在节点模块 asar 文件夹 package.json 中:
"standard": {
"env": {
"mocha": true
},
"globals": [
"BigInt"
]},
我尝试将其更改为:
"standard": {
"env": {
"es2020": true,
"browser": true,
"node": true,
"mocha": true
},
"globals": {
"BigInt":true
}},
我还是没有工作
上次更新已解决
Electron 运行它自己的 nodejs 版本,而我没有最后一个包版本。一旦我更新了电子包,一切正常!希望这会对某人有所帮助
【问题讨论】:
-
这个错误听起来好像你没有足够新的nodejs版本,因为
BigInt是在v10.4中添加的,错误来自asar包lib/filesystem.js中的这行代码:this.offset = BigInt(0)。所以,我建议你重新检查一下你的电子版本实际使用的是什么版本的 nodejs。 -
确切地说,Electron 运行不同的 nodejs 版本,所以我必须更新我的电子包以获取最新的 nodejs 版本并且它工作!