How to set NODE_ENV to production when relying on node buildpack?

Here is a deployment. Does anyone know how to make NODE_ENV production during the buildpack run process?

1 Like

I’ve been wondering this myself too.

I tried NODE_ENV=production fly deploy but it didn’t work.

You might try the suggestions in the official Buildpack docs and set one of these:

NPM_CONFIG_PRODUCTION=true
YARN_PRODUCTION=true

On Fly, the way to set these is via fly.toml build arguments or on the command line.

See App Configuration (fly.toml) · Fly Docs

Where would those be set exactly?

Another issue is I am using PnPM.

You can put on your fly.toml like this:

app = "your-app-name"

[build.args]
NODE_ENV = "production"

Then the deployed image will recognize NODE_ENV during build time too

Sorry, seeing now that was mentioned before.

Thanks all!

1 Like