#SyntaxError on passing `define` argument while compiling
1 messages · Page 1 of 1 (latest)
maybe you can try setting NODE_ENV outside the build command?
NODE_ENV=production bun build src/index.ts --minify --compile --target=bun-windows-x64 --sourcemap --outfile dist/targets/bin
actually for powershell it would be $Env:NODE_ENV = 'production' instead of NODE_ENV=production
The value passed to the define flag are “literally” replaced, so in your case with the command you provided if (process.env.NODE_ENV === 'development') {…} will be if (development === ‘development') {…} but here the variable development does not exist
You need to use quotes
I was trying something new, i wrote a script to bundle this and found that process.env does not get replaced, i think this is because of double quotes.
process.env
Explicitly write a undeclared variable
in index.js the node_env value is defined as a variable but the other env variable is written the same way without double quotes i tried the other way adding "development" in .env and does not works
But in counterpart of my first image, defining Bun.env does replace