Ensure NODE_ENV is production when deploying on Now #1106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As @matheuss pointed out in the #now Slack channel, NODE_ENV should probably be set explicitly for deploying on Now.
This example code uses
next build
which implicitly doesn't create a dev server (AFAIK), so it works as it is, but it gives the impression that you could just switch"build": "next build"
with"build": "node server.js"
when going for a custom server. But probably (based on the example in same README), you'll declare the server asconst app = next({ dev: process.env.NODE_ENV !== 'production' });
, meaning that unless NODE_ENV is explicitly set, the deployment will fail (becausedev
will betrue
, and thus will try to write to the.next
directory which isn't writable on Now (EACCES: permission denied, rmdir '/home/nowuser/src/.next'
).So I thought it'd be better to educate people that they should set NODE_ENV somehow.