Next.js ignoring NODE_ENV=development

Viewed 1290

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:

> admin-ui@1.0.0 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.

1 Answers

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.

Related