Skip to content

Unnecessary package.json required for use with Deno #13743

Closed
@markmals

Description

@markmals

Summary

When running @react-router/dev in Deno without a package.json file (which is unnecessary, as Deno uses its own deno.json(c) configuration format), it throws an error because it cannot find the package.json file to verify that @react-router/node and isbot are installed. These packages only need to be installed when the developer has not supplied a custom entry.server.(j|t)sx file.

As it see it, there are two possible solutions, and they could be implemented incrementally as well:

  1. Do not validate the existence of a package.json file when the developer has supplied a custom entry.server.(j|t)sx file. This will allow the developer to use a custom server entry file with Deno to skip the package.json check.
  2. Validate the existence of deno.json(c) if neither a package.json nor a custom entry.server.(j|t)sx file were found. Because of Deno's excellent Node compatibility support, @react-router/node is fully compatible with Deno (if you revert to using a package.json file with Deno today). There is likely some sort of performance deficit between a pure-Deno custom entry.server.(j|t)sx file and using @react-router/node through the compatibility layer, but I'm not sure how dramatic it would be. It's probably smart to encourage developers to use a custom entry.server.(j|t)sx file with Deno by making that the default in the template (it is today), but I think it's worth considering validating @react-router/node in deno.json(c) for developers who want to get up and running easily with as little configuration or complexity as possible and aren't concerned about the possible performance differences.

I'm using React Router as a…

framework

Reproduction

Delete the package.json file from this template and run deno task dev: https://github.com/remix-run/react-router-templates/tree/main/deno

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M4
    Memory: 111.78 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.16.0 - ~/.volta/tools/image/node/22.16.0/bin/node
    npm: 10.9.2 - ~/.volta/tools/image/node/22.16.0/bin/npm
    pnpm: 10.11.0 - ~/.volta/bin/pnpm
    bun: 1.2.15 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 137.0.7151.68
    Safari: 18.5

Used Package Manager

npm

Expected Behavior

  • React Router should work in Deno environments without requiring a package.json file.
  • Since Deno does not use package.json for dependency resolution, the code path that tries to load or reference package.json should be skipped when running under Deno (or replaced by a Deno-friendly entry point).

Actual Behavior

  • Any calls to the react-router binary fail if no package.json is found.
  • Users are forced to add an inert package.json with a comment field merely to satisfy @react-router/dev's import logic, which doesn’t make sense for Deno.

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