Next.js Discord

Discord Forum

non-standard NODE_ENV

Answered
Highlander posted this in #help-forum
Open in Discord
HighlanderOP
I am deploying my nextjs app on railway and I believe what is happening is that my env cant be read by the app.

This typeerror happens when the auth provider I am using (Clerk) cant get the key from the env.

I am not doing anything manually with the NODE_ENV and it just started throwing this "non-standard NODE_ENV" error. I cant repro it locally - everything is working fine locally.

I am not sure where to go from here - looking for any troubleshooting advice!! I didnt make any changes to the next.config.ts

const nextConfig = {
  reactStrictMode: true,

  typescript: {
    tsconfigPath: "./tsconfig.json",
  },

  experimental: {
    externalDir: true,
  },

  images: {
    domains: ['tailwindui.com'],
  },

  webpack: (config) => {
    config.module.rules.push({
      test: /.*\.svg$/i,
      issuer: { and: [/\.(js|ts|md)x?$/] },
      use: [
        {
          loader: "@svgr/webpack",
          options: {
            svgo: true,
            dimensions: false,
          },
        },
      ],
    });

    return config;
  },

  sentry: {
    hideSourceMaps: true,
    disableServerWebpackPlugin: !enableSentryUpload,
    disableClientWebpackPlugin: !enableSentryUpload,
  },

  publicRuntimeConfig: {
    version,
    API_BASE_URL: process.env.API_BASE_URL,
    CLERK_PUBLISHABLE_KEY: process.env.CLERK_PUBLISHABLE_KEY,
    GOOGLE_MAPS_API_KEY: process.env.GOOGLE_MAPS_API_KEY,
  }
};
Answered by Highlander
resolved - someone changed the package.json scripts, and it was running next dev instead of next start
View full answer

5 Replies

if you are deploying the server in railway make sure you are setting the NODE_ENV as production when starting the server:
"start": "NODE_ENV=production next start"
HighlanderOP
i have never done that before - is there a reason you can think of that i suddenly need to?
this app has been up for a month or two
seeminly randomly it started failing deploys with this error yesterday
HighlanderOP
resolved - someone changed the package.json scripts, and it was running next dev instead of next start
Answer