英文:
Electron: process.platform undefined
问题
我的全局变量 process
在我的 Electron 应用程序打包后未设置。它只包含以下信息:{"title":"browser","browser":true,"env":{},"argv":[],"version":"","versions":{}}
。
在我的代码中没有操作 process
,像 process.platform
这样的信息只在开发模式下可用。我正在使用 electron-builder(v23.6.0)和 electron(v23.1.3)。
我在使用 electron-updater 时发现了这个问题。这个包使用诸如 process.platform
或 process.resourcesPath
的变量,所以我猜想我的情况并不正常。
英文:
My global variable process
is not set when my electron app is packaged. It only contains these info: {"title":"browser","browser":true,"env":{},"argv":[],"version":"","versions":{}}
.
process
is not manipulated in my code and info like process.platform
are only available in development mode. I'm using electron-builder (v23.6.0) and electron (v23.1.3).
I found this problem when using electron-updater. This package uses variables like process.platform
or process.resourcesPath
so I guess it's not normal that mine is that empty.
答案1
得分: 0
我通过显式导入 'process' 包来找到了解决方案,就像这样:
import prcs from 'process'
我以为在主进程中可以不这样做就能访问它,因为在其他Node.js应用中是可能的。显然不是这样。
英文:
I found a solution by explicitly importing the 'process' package like so
import prcs from 'process'
I assumed it would be accessible in the main process without doing that since it's possible in other nodeJS applications. Apparently not.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论