Next.js: Environment variables no longer passed to app in 9.5 ("ReferenceError: process is not defined")

Created on 28 Jul 2020  路  5Comments  路  Source: vercel/next.js

Bug 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

Screen Shot 2020-07-28 at 7 15 29 AM

System information

  • OS: macOS
  • Browser: Chrome 84.0.4147.89
  • Version of Next.js: 9.5
  • Version of Node.js: 10.20.1

Most helpful comment

See #13341, webpack 5 does not provide process and Buffer but we will to ensure existing apps don't break.

All 5 comments

Did you try out the webpack 5 beta? Because that would cause this (expectedly).

@timneutkens just came to the same conclusion, was on webpack 5 beta. Remove it and it works fine :)

Any clue why webpack 5 beta does that? And how I can mitigate it (when it is no longer beta)?

This can be closed

See #13341, webpack 5 does not provide process and Buffer but we will to ensure existing apps don't break.

I merged the PR to add it earlier today btw: https://github.com/vercel/next.js/pull/15499

Was this page helpful?
0 / 5 - 0 ratings