2021年3月28日星期日

Electron does not get valid version data through the app.getVersion() command

I cannot understand why my app cannot gets correct version data.

I already add version line in my package.json and I use vue-electron so I write my code in this update component.

<template>    <Window title='Program Updater'>      <div class='wrap' id='currentAppVersion'>        Current App Version :       </div>      <div class='wrap' id='checkNewVersion'>        Latest App Version :       </div>      <button class='login' @click="$emit(updateCheck ? 'exist' : 'latest')"></button>    </Window>  </template>  

And in area I add this codes to get version data from package.json. But it shows 'electron package' version and I don't know why it related with.

enter image description here
[part of my index.vue]

const electron = require('electron')  const app = electron.app || electron.remote.app      data () {      return {        currentAppVersion: app && app.getVersion(),        latestAppVersion: 'Not yet Developed'      }    }  

At first I thought the error is from electron version is so low. But I read 3.1.X document there is app.getVersion() method and I don't know how to fix it.

Some person said that I can use 'process.env.npm_package_version' command and actually, it works. But in production mode it return no data.

https://stackoverflow.com/questions/66848230/electron-does-not-get-valid-version-data-through-the-app-getversion-command March 29, 2021 at 10:56AM

没有评论:

发表评论