-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
"process.env.NODE_ENV" is defined as an identifier instead of a string #583
Comments
It's in #466
Shells are messy. I think it's good you opened this issue so there's now something people can search for |
The answer is in the documentation for the define feature: https://esbuild.github.io/api/#define. Your shell is removing the outer layer of quotes. That means by the time esbuild sees it, it’s as if you never had any quotes in the first place. This is why it gives you this warning. While it’s true that using two layers of quotes works for bash (since bash will only remove the outer layer of quotes), this isn’t portable to Windows command prompt. The portable approach is to escape the quotes in the shell command using a backslash like this: "build:dev": "esbuild index.ts --bundle --define:process.env.NODE_ENV=\\\"development\\\" --minify --sourcemap --platform=browser --outfile=dist/index.development.js" |
Ooooh, I had tried to double them but hadn't tried tripling them. admittedly only looked as far as the "bundling for browser" docs 🙈 Thank youuuuu!! |
No worries. I'm going to close this issue since it sounds like it has been resolved. |
For anyone else wondering how to do this in the JS API, this appears to work: require('esbuild').buildSync({
define: { 'process.env.NODE_ENV': '"production"' },
}) I intially expected that I'd have to turn the |
I have tried using single as well triple quote , yet still the terminal is generating error. I am currently using Windows 10 and terminal i am using is bash The command i am trying to run is: I have even tried using single slash as well..but it still didin't work
Error Output for triple quote statement is somewhat like this. As for single quote statement It would be a great help if anyone could solve it..i have been stuck here for a while now |
One potential way to fix this is to just remove the |
I'm trying to use
esbuild
on a mac with the following script:But I always get the following warning:
I've tried single quotes without luck also. Is this warning being incorrectly reported or am I doing something wrong here?
The text was updated successfully, but these errors were encountered: