javascript - How do I post App version with JS electron - Stack Overflow

I want to post the version of my app but instead I got this weird error. Does someone see what's w

I want to post the version of my app but instead I got this weird error. Does someone see what's wrong, because I can't see it. (Node.js is included)

error: Unexpected token <

<script>
  console.log(process);
   let output =
  <h2 class="page-header">App version Data</h2> 
   <ul class="list-group"> 
    <li class="list-group-item">Node: ${process.versions.node}</li>
     </ul>

   document.getElementById('output').innerHTML = output;
</script>

I want to post the version of my app but instead I got this weird error. Does someone see what's wrong, because I can't see it. (Node.js is included)

error: Unexpected token <

<script>
  console.log(process);
   let output =
  <h2 class="page-header">App version Data</h2> 
   <ul class="list-group"> 
    <li class="list-group-item">Node: ${process.versions.node}</li>
     </ul>

   document.getElementById('output').innerHTML = output;
</script>
Share Improve this question edited Apr 9, 2019 at 11:33 Stijn van Woerkom asked Apr 8, 2019 at 9:58 Stijn van WoerkomStijn van Woerkom 352 silver badges12 bronze badges 2
  • 1 Right now you are showing your node version instead of app version – Mayank Vadiya Commented Apr 8, 2019 at 13:16
  • Are you missing backticks, I'm not seeing where the string starts/ends? Also, what is the --> doing in the code? – snwflk Commented Apr 8, 2019 at 17:25
Add a ment  | 

2 Answers 2

Reset to default 2

On your client-side Javascript, you could require remote to obtain the version of your application:

var appVersion = require("electron").remote.app.getVersion();

remote (https://electronjs/docs/api/remote)

Use main process modules from the renderer process.

Example of how I'm using it to determine app version.

process.versions.node is only available in Nodejs. Here you are trying to get the version number from a client side JavaScript(I assume..) which will not work.

You could expose a nodeJs api and write a Get request to get the vetsion in front end.

The electron have the following API for getting the app version, which gets the version from package.json. https://electronjs/docs/api/app#appgetversion

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745615216a4636192.html

相关推荐

  • javascript - How do I post App version with JS electron - Stack Overflow

    I want to post the version of my app but instead I got this weird error. Does someone see what's w

    9小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信