Skip to content

ENABLE_DEV_WARNINGS is true in production since v7.0.2 due to always-resolving development build #14102

@onozaty

Description

@onozaty

Reproduction

You can reproduce this issue using the following environment:

Steps:

  1. Open the StackBlitz project
  2. Run the following commands in the terminal:
    npm run build && npm run start
  3. Visit a non-existent URL, such as /abc
  4. You will see the following development-only warning in the console:
GET / 200 - - 57.135 ms
Error: No route matches URL "/abc"
    at getInternalRouterError (file:///home/projects/github-fpqca3jn/node_modules/react-router/dist/development/chunk-C37GKA54.mjs:4731:5)
    at Object.query (file:///home/projects/github-fpqca3jn/node_modules/react-router/dist/development/chunk-C37GKA54.mjs:2892:19)
    at handleDocumentRequest (file:///home/projects/github-fpqca3jn/node_modules/react-router/dist/development/chunk-KIUJAIYX.mjs:1344:40)
    at requestHandler (file:///home/projects/github-fpqca3jn/node_modules/react-router/dist/development/chunk-KIUJAIYX.mjs:1259:24)
No routes matched location "/abc"
GET /abc 404 - - 20.615 ms

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @react-router/dev: ^7.7.1 => 7.7.1 
    @react-router/node: ^7.7.1 => 7.7.1 
    @react-router/serve: ^7.7.1 => 7.7.1 
    react-router: ^7.7.1 => 7.7.1 
    vite: ^6.3.3 => 6.3.5

Used Package Manager

npm

Expected Behavior

When running in a production environment (NODE_ENV=production), development-only warnings like No routes matched location should not be shown.
The internal flag ENABLE_DEV_WARNINGS should be false, and the production build (dist/production) should be used.

Actual Behavior

Even with a production build and NODE_ENV=production, accessing a route that does not exist (e.g. /abc) prints the following development warning:

No routes matched location "/abc"

This is caused by dist/development being resolved instead of dist/production, which sets:

  • ENABLE_DEV_WARNINGS = true

As a result, development-only logs are shown in production.

Additional Context

This issue appears to have been introduced in PR #12437, which modified the exports field in package.json to always point to the development build for Node.js environments:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions