Electron:process.platform 未定义

huangapple go评论61阅读模式
英文:

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.platformprocess.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.

huangapple
  • 本文由 发表于 2023年3月9日 19:48:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75684190.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定