nexe/nexe

Using log4js with nexe

hgleam opened this issue · 1 comments

What happened:
Error: Cannot find module 'flatted

What you expected to happen:
No errors

How to reproduce it (as minimally and precisely as possible):
source man.ts

import Log4js from 'log4js';
require('log4js/lib/appenders/file')
require('log4js/lib/appenders/stdout')
Log4js.configure({
    appenders:{ startBroker:{type:'file',filename:'Mosca.log'}},
    categories:{default:{appenders:['startBroker'],level:'info'}}
});
let logger = Log4js.getLogger('start apps');
logger.info('hello apps');

compile

tsc

build

nexe main.js -t windows-x64-14.15.3

Preparation for distribution

Move the executable file to another directory for distribution

Before moving:/c/Users/xxxx/Desktop/aaaa/log4js-test
After moving:C:\Users\xxxx\Desktop\program\app

Anything else we need to know?:
Nothing.

Environment:

  • Platform(OS/Version):Windows 10 Pro 64bit
  • Nexe version:4.0.0-rc.2

It's working correctly here on Linux using 4.0.0-rc.2, so not sure what the issue is unfortunately :-/

It might be worth trying a npm ci and a nexe --clean before trying again?

Something that might help debugging would be setting DEBUG='nexe:require' as an environment variable, as then nexe will log attempts to find the relevant modules, e.g.

$ DEBUG='nexe:require' ./log4js-test 2>&1|grep flatted
...
[nexe] - read     (hit)              .../node_modules/flatted/package.json
[nexe] - stat     (hit)              .../node_modules/flatted/cjs/index.js   0
[nexe] - read     (hit)              .../node_modules/flatted/cjs/package.json