Environment variables no longer passed to app in 9.5 ("ReferenceError: process is not defined")
See original GitHub issueBug report
Describe the bug
Process object used to access environment variables in node is missing after upgrading to 9.5.
To Reproduce
Upgraded to nextjs 9.5 and the snippet in the screenshot broke. If I start the app using a command like this NEXT_PUBLIC_LOCAL_FUNCTIONS_PORT=5001 next
it works, but if I leave out the environment in the command (i.e. next
) it fails.
Tried creating a fresh next app (on 9.5) and was NOT ABLE to reproduce. Might be something with my dependencies.
Expected behavior
I expected that env variables would be able to be looked up on the client.
Screenshots
System information
- OS: macOS
- Browser: Chrome 84.0.4147.89
- Version of Next.js: 9.5
- Version of Node.js: 10.20.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
ReferenceError: “process is not defined” - GIMTEC
In NodeJS, “process” is defined, but not in the browser. This is because NodeJS and the browser are different runtime environments.
Read more >javascript - Uncaught ReferenceError: process is not defined
Node.js code must be run by the node process, not the browser (the code must run in the server). To run the code,...
Read more >Firebase JavaScript SDK Release Notes - Google
The SDK no longer causes React Native to log a warning about deprecation of AsyncStorage ... where the SDK tried to access fields...
Read more >process is not defined / how to use environment variables in ...
I have a plain HTML/CSS/JavaScript page - no Node, no frameworks, just plain old HTML/CSS/JS. How do I access environment variables from my...
Read more >Passing the environment variables to Cypress - YouTube
Using either --env or plugin file. The plugin file way is the most powerful way to pass the environment variables, plus it makes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@7iomka it is not possible to use destructuring with process.env in next.js. Line 17 is an error, but you can still define them one by one and it should work.
Explaination about why is here: https://github.com/vercel/next.js/issues/6888. It is because of a webpack plugin.
Destructuring env variables caused
process is not defined
error. By exporting them one by one, my app is working just fine. Thank you so much!