-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Closed
Labels
Description
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:
- Do not validate the existence of a
package.jsonfile when the developer has supplied a customentry.server.(j|t)sxfile. This will allow the developer to use a custom server entry file with Deno to skip thepackage.jsoncheck. - Validate the existence of
deno.json(c)if neither apackage.jsonnor a customentry.server.(j|t)sxfile were found. Because of Deno's excellent Node compatibility support,@react-router/nodeis fully compatible with Deno (if you revert to using apackage.jsonfile with Deno today). There is likely some sort of performance deficit between a pure-Deno customentry.server.(j|t)sxfile and using@react-router/nodethrough the compatibility layer, but I'm not sure how dramatic it would be. It's probably smart to encourage developers to use a customentry.server.(j|t)sxfile with Deno by making that the default in the template (it is today), but I think it's worth considering validating@react-router/nodeindeno.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.5Used 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-routerbinary fail if nopackage.jsonis found. - Users are forced to add an inert
package.jsonwith a comment field merely to satisfy@react-router/dev's import logic, which doesn’t make sense for Deno.