Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SetTimeout with nexe #1042

Open
hgleam opened this issue Mar 21, 2023 · 1 comment
Open

Using SetTimeout with nexe #1042

hgleam opened this issue Mar 21, 2023 · 1 comment
Labels

Comments

@hgleam
Copy link

hgleam commented Mar 21, 2023

What happened:
Error: Cannot find module 'timers/promises'

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'timers/promises'
Require stack:
- E:\develop\xxxxxxxx\sleep-test\main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (E:\develop\xxxxxxxx\sleep-test\main.js:12:20)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'E:\\develop\\xxxxxxxx\\sleep-test\\main.js' ]
}

What you expected to happen:
No errors

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

import { setTimeout } from "timers/promises";

async function test() {
    const isRunning = true
    while (isRunning) {
        console.log('Running...')
        await setTimeout(10000)
    }
}
test()

compile
tsc

build

nexe main.js -t windows-x64-14.15.3

Anything else we need to know?:
Nothing.

Environment:

  • Platform(OS/Version):Windows 10 Pro 64bit
  • Nexe version:4.0.0-rc.2
@hgleam hgleam added the bug label Mar 21, 2023
@bruce-one
Copy link
Contributor

bruce-one commented Apr 13, 2023

timers/promises was only added to Node in v15/v16 by the look of the docs - https://nodejs.org/api/timers.html#timers-promises-api

So you'd need to target a newer version of node (e.g. -t 18.15.0), which would also mean you'd need to use the --build argument (harder) or use prebuilt artefacts from a source like https://github.com/urbdyn/nexe_builds (e.g. it looks to have windows-x64-16.19.0 - although when I tried it it looked to have a bug with those builds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants