yao-pkg / pkg

Package your Node.js project into an executable
https://www.npmjs.com/package/@yao-pkg/pkg
MIT License
312 stars 11 forks source link

NODE_OPTIONS environment variable not work #20

Open cage1618 opened 7 months ago

cage1618 commented 7 months ago

What version of pkg are you using?

5.11.1

What version of Node.js are you using?

20.10.0

What operating system are you using?

windows

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node20

Describe the Bug

How can I dynamically set the environment variable '--max-old-space-size' during runtime, for example using the command

NODE_OPTIONS=--max-old-space-size=8192 ./hello.exe

Currently, this approach is not taking effect.

Using --options=max-old-space-size=8192 is not working; the resulting package has a fixed 'max-old-space-size' of 8192 during runtime.

Expected Behavior

support dynamic pass NODE_OPTIONS to runtime.

To Reproduce

NODE_OPTIONS=--max-old-space-size=8192 ./hello.exe

robertsLando commented 7 months ago

Setting env vars on windows doesn't work like that: https://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-on-windows

cage1618 commented 7 months ago

I use tauri build a cross platform application, I want to dynamic pass max-old-space-size by NODE_OPTION to Command.sidecar env option, how can I do this?

kayahr commented 4 months ago

Same problem here. Need to increase the heap size but NODE_OPTIONS is ignored when application is packaged into binary. It only works by hard coding it with --options max-old-space-size=4096 parameter when calling pkg. Would be nice to be able to configure it during runtime.