最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论