4

In my package.json, I have a build script set to build my next project as follows:

"build": "echo \"$NODE_ENV\" && NODE_ENV=$NODE_ENV next build && npm run build-server",

The output from the command that I get is:

> [email protected] build /usr/src/admin-ui
> echo "$NODE_ENV" && NODE_ENV=$NODE_ENV next build && npm run build-server

development
Creating an optimized production build ...

The echo outputs development as the value for $NODE_ENV. However, I cannot get that passed to next. It just ignores it.

Using next.js version 9.0.5.

4

1 Answer 1

1

next build generates production builds

next dev creates a development build - https://nextjs.org/docs/api-reference/cli#development

Build usually is nomenclature for production builds and dev for a development server.

When you do next build it assumes that its preparing for production and continues to do so.

2
  • 5
    This is kind of silly and I definitely believe it shouldn't ignore an explicit setting. I'm building a docker image and that's why I need to build first (prod and dev have the same Dockerfile).
    – Gezim
    Jul 1, 2020 at 11:22
  • 1
    Note that NODE_ENV is used in a special way in Next.js. (I could not find reliable information on how it behaves, but it definitively has a special meaning.)
    – kca
    Sep 27, 2021 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.