最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin5PV0评论

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

Post a comment

comment list (0)

  1. No comments so far