how to get packaged app version #554

feverzy2 opened this Issue Mar 20, 2013 · 7 comments


None yet

3 participants


hi,i'm new here,
i just found node-webkit so amazing !
follow some steps,
i can easily package my html app into a native windows desktop app,

but when i try to achieve app auto update。
i can't find a way to get current app version to compare with the server。

any help will be thankful!


i found there is a ‘version’ attribute in package.json

but how can't i get it?

Mithgol commented Mar 20, 2013

If you have attached a zip-packed archive to the tail of the node-webkit's binary, then, knowing the initial size of that binary, you may:

  1. use node-fs-ext to seek past that position,
  2. read the rest (that zip archive),
  3. use JSZip to unpack package.json from that archive,
  4. then parse JSON to get the version.

i tried read package.json with out unpack the zip file.
it worked.

fs.readFile('package.json','utf8', function (err, data) {
      if (err) throw err;

i just want to know if there is an api support 。


Not currently, but it's on our plan. You can watch #360 to track it. Thanks.


thanks to notify.
here’s my way to download update and run it.
l'd like to share it.

    var gui = require('nw.gui')
    ,execPath= process.execPath
    ,filePath =execPath.substr(0,execPath.lastIndexOf("\\"));

    var http = require('http')
  , fs = require('fs')
  , options,fileName='some.exe'

    options = {
        host: ''
      , port: 80
      , path: '/'+fileName

    var request = http.get(options, function(res){
        var data = ''

        var rln=0,ln=res.headers['content-length'];     
        res.on('data', function(chunk){
                //update UI

            data += chunk
        res.on('end', function(){               
                console.log('File saved.')
            fs.writeFile(filePath+'/'+fileName, data, 'binary', function(err){
                if (err) 
@rogerwang rogerwang referenced this issue Jul 25, 2013

App.Version #920

Mithgol commented Jul 25, 2013

I have to add the following to my previous comment.

When your application is running, it's unpacked already.

That's why, to get your own application's version, you do not have to read the engine's tail and unzip.

Just require('./package.json').version, and you've got the version.


closing it since #360 is resolved.

@rogerwang rogerwang closed this Aug 3, 2013
@feverzy2 feverzy2 changed the title from how to get packaged app version to how to get packaged app version Apr 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment