Nexe: Nexe does not bundle the js files

Created on 29 Apr 2019  路  4Comments  路  Source: nexe/nexe

Is this a BUG or a FEATURE REQUEST?:
Bug
What happened:

nexe server.js -o dist/server.exe

executed server.exe in dist

Result:

Error: Cannot find module 'c:\Users\sascha\PhpstormProjects\server\dist\server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at Object.<anonymous> (c:\Users\sascha\PhpstormProjects\server\dist\server.exe:349

What you expected to happen:

The .exe should just run

How to reproduce it (as minimally and precisely as possible):

Difficult, it seems the js files are not bundled at all. Tried with various glob patterns, but it's like no translation to the virtual file systems is happening at all... If I copy the server.js into the dist directory, the file is found but loading other code underneath "src" fails.

Anything else we need to know?:

AFAIR the build worked with version 2.

Environment

  • Platform(OS/Version): Windows 10 x86
  • Host Node Version: 10.15.0
  • Target Node Version: windows-x64-10.15.0
  • Nexe version: 3.2.0
  • Python Version: 2.7.15
bug needs-reproduction

Most helpful comment

I had the same issue. You are going to import file from wrong drive letter. You have to import C:\, not c:. I've triggered this issue in Process.spawn when used process.cwd() in path. Look at these issues:
https://github.com/nodejs/node/issues/6624
https://github.com/nodejs/node/issues/7215

All 4 comments

Hi @sascha-schieferdecker I can't seem to reproduce this... If you can provide some sort of minimal reproduction that would help!

I checked with a file containing a simple console.log("Hello"). Works just fine. But this is my main entry point and nothing is included:

require('dotenv').config()
const cli = require('commander')
const sqlite = require('sqlite')
const fs = require('fs')
const nodeCleanup = require('node-cleanup');

// Bind translation to global.i18n
const i18n = require('i18n')
i18n.configure(
  {
    defaultLocale: 'en',
    directory: process.cwd() + '/locales',
    objectNotation: true
  }
)

global.i18n = i18n

/* Check Development Environment Start */
const isDevelopment = process.env.DEVELOPMENT
if (isDevelopment) {
  console.log('Development mode enabled')
}
/* Check Development Environment End */

cli
  .version('Version 0.2.0 Build 2019-04-25-01')
  .option('--hostname <hostname>', 'Hostname for serving the clients.')
  .option('--port [port]', 'Port to listen on', 5358)
  .option('--debug', 'Verbose logging')
  .parse(process.argv)

// Init Environment global variables start
homedir = require('os').homedir();
datadir = homedir + '/Uniserver'
if (!fs.existsSync(datadir)){
  fs.mkdirSync(datadir);
}
if (!fs.existsSync(datadir + '/reports')){
  fs.mkdirSync(datadir + '/reports')
}

global.pdfJobcount = 0
global.userDataPath = datadir
global.dbFile = userDataPath + '\\server.db'
global.logDir  = userDataPath + '\\logs\\'
global.doDebug = cli.debug
if (global.doDebug) {
  console.log('logDir: ' + logDir)
  console.log('dbFile: ' + dbFile)
}

// Logger instantion after init logdir
const logger = require('./src/logging/serverLogger')

if(cli.hostname === undefined) {
  logger.error('Cannot start without hostname', new Error())
  console.error('Critical error: Cannot start without hostname')
  process.exit(1)
}

// Init Environment end

const migrateDatabase = new(require('./src/actions/migrateDatabase'))()
const logbookRepository = new(require('./src/repositories/logbookRepository'))()

migrateDatabase.migrate().then(() => {
  let schedulerActions  = new(require('./src/actions/schedulerActions'))
  schedulerActions.init().then(() => {
    // log application start
    logbookRepository.logApplicationStart().then(() => {
      // Finally start API server
      serverApi = new(require('./src/api/serverApi'))(cli.port, cli.hostname)
      // Register handler to log application exit
      nodeCleanup((exitCode, signal) => {
        if (signal !== null) {
          logbookRepository.logApplicationStop().then(() => {
            process.kill(process.pid, signal);
          })
          nodeCleanup.uninstall()
          return false
        }
      })
    }).catch((err) => {
      logger.error('Cannot log application start', new Error(err))
    })
  }).catch(err => {
    logger.error('Scheduler cannot be started', new Error(err))
  })
}).catch((err) => {
  logger.error('Migration failed', new Error(err))
})

Noteworthy modules used: sqlite, express, puppeteer, winston for logging

It is strange. If I run the .exe from a terminal within phpstorm it works. But if I simply open a Windows CMD shell, the error of the missing entrypoint server.js is shown... Maybe there is a kind of environment missing?

BTW, this does not happen if I use pkg, but it complicates the deployment with puppeteer. I was happy to have found nexe. This behaviour is quite puzzling.

I had the same issue. You are going to import file from wrong drive letter. You have to import C:\, not c:. I've triggered this issue in Process.spawn when used process.cwd() in path. Look at these issues:
https://github.com/nodejs/node/issues/6624
https://github.com/nodejs/node/issues/7215

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryancat picture ryancat  路  6Comments

jgoux picture jgoux  路  5Comments

beppe9000 picture beppe9000  路  4Comments

ricardopolo picture ricardopolo  路  6Comments

transitive-bullshit picture transitive-bullshit  路  6Comments