question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting NODE_ENV to 'staging' causes builds to fail

See original GitHub issue

Bug report

Describe the bug

Setting NODE_ENV to ‘staging’ causes next build to fail on a Webpack “unexpected token” error - presumably the first time it encounters JSX.

To Reproduce

  1. Create a Next.js app with JSX in it
  2. NODE_ENV=staging npm run build
  3. ???
  4. Failure

Expected behavior

Probably shouldn’t fail.

Screenshots

Screen Shot 2020-01-16 at 10 49 25 AM

System information

  • OS: macOS, whatever Linux Heroku runs
  • Version of Next.js: 9.2.0

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ijjkcommented, Jan 17, 2020

Hi, setting NODE_ENV to staging instead of the default values we set is not ideal as this will cause things to potentially mismatch

~One case of where this will cause problems is when bundling react if you set NODE_ENV to a value other than production during a production build the development bundle will be used, see here for related code~

EDIT: It looks we override this value during bundling so the above isn’t a concern although can lead to mismatches due to not overriding with next start or when loading Babel or Next configs

0reactions
balazsorban44commented, Jan 30, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting NODE_ENV to 'staging' causes builds to fail #10129
Setting NODE_ENV to 'staging ' causes next build to fail on a Webpack "unexpected token" error - presumably the first time it encounters...
Read more >
Do not use NODE_ENV for staging - Gleb Bahmutov
When running on staging or production, I set NODE_ENV variable on the server to staging or production . This value then lets my...
Read more >
Why is process.env.NODE_ENV undefined? - Stack Overflow
process.env is a reference to your environment, so you have to set the variable there. To set an environment variable in Windows: SET...
Read more >
Managing .env variables for provisional builds with Create ...
What if you want to setup .env.staging ? This article will show you how to manage environment variables for provisional builds.
Read more >
Environment variables - AWS Amplify Hosting
In the Amplify console, choose App Settings, then choose Build settings. In the App build specification section, choose Edit. Add the environment variable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found