Nexe: Cannot read property 'version' of null

Created on 1 Dec 2017  路  4Comments  路  Source: nexe/nexe

This is a

  • [X] Bug Report
  • [ ] Feature Request
  • [ ] Other


  1. Build an application with nexe.
  2. When trying to run windows executable:
exports.version = require('./package').version;

TypeError: Cannot read property 'version' of null

It looks like this line should be corrected to require('./package.json').version or loading of json files as js files explicitly enabled in rollup/webpack



  • Platform(OS/Version): Ubuntu 17.04
  • Host Node Version: 9.2.0
  • Target Node Version: 9.2.0
  • Nexe version: 2.0.0-rc.22
  • Python Version: 2.7.12+
bug

Most helpful comment

Okay, Here is a workaround to bypass the bundler

nexe entry-file.js --bundle ./nexe-bundle.js

and nexe-bundle.js (requires two dependencies pify and webpack

const webpack = require('pify')(require("webpack"))
const fs = require('fs')

module.exports.createBundle = function (options) {
    return webpack({
        entry: options.input,
        target: 'node',
        output: { filename: 'tmp.js' }
    }).then(() => {
        const result = fs.readFileSync('./tmp.js').toString()
        fs.unlinkSync('./tmp.js')
        return result
    })
}

All 4 comments

Sorry, Working on resolving this -- #418

To clarify, it works if you use require("./package.json")?

Heya - it's not actually something I'm doing. Appears to be nexe.

I tried creating package.js to fool it and just exporting the contents of package.json module.exports = require('package.json') but to no avail.

Okay, Here is a workaround to bypass the bundler

nexe entry-file.js --bundle ./nexe-bundle.js

and nexe-bundle.js (requires two dependencies pify and webpack

const webpack = require('pify')(require("webpack"))
const fs = require('fs')

module.exports.createBundle = function (options) {
    return webpack({
        entry: options.input,
        target: 'node',
        output: { filename: 'tmp.js' }
    }).then(() => {
        const result = fs.readFileSync('./tmp.js').toString()
        fs.unlinkSync('./tmp.js')
        return result
    })
}

Thanks for that :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Greg-openface picture Greg-openface  路  6Comments

beppe9000 picture beppe9000  路  4Comments

affanshahid picture affanshahid  路  3Comments

transitive-bullshit picture transitive-bullshit  路  6Comments

vickylance picture vickylance  路  4Comments