Skip to content

Fresh create-rs-router app or #3719

Closed
Closed

Description

@jimjeffers

Which project does this relate to?

Router

Describe the bug

When I attempt to launch the local server using yarn start (via fresh create-ts-router app) or yarn dev (via ts router quick start) I get the following error when I add the TanStackRouterVite plugin:

Error: Build failed with 2 errors:
node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtools.js:2:43: ERROR: Could not resolve "@tanstack/router-devtools-core"
node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtoolsPanel.js:3:48: ERROR: Could not resolve "@tanstack/router-devtools-core"
    at failureErrorWithLog (/Users/jimjeffers/Sites/my-app/node_modules/esbuild/lib/main.js:1477:15)
    at /Users/jimjeffers/Sites/my-app/node_modules/esbuild/lib/main.js:946:25
    at /Users/jimjeffers/Sites/my-app/node_modules/esbuild/lib/main.js:1355:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

In my config I have the following:

import { defineConfig } from "vite";
import viteReact from "@vitejs/plugin-react";
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [TanStackRouterVite({
    target: 'react',
    autoCodeSplitting: true,
  }),
  viteReact()],
  test: {
    globals: true,
    environment: "jsdom",
  },
  build: {
    rollupOptions: {
      external: ['@tanstack/router-devtools-core']
    }
  }
});

Note I tried to move dev tools into external deps and still had no luck. When I clicked the link below for the file-based routes starting point on stackblitz the build fails with the same error without making any changes!

> dev
> vite --port 3000


♻️  Generating routes...
✅ Processed routes in 233ms

  VITE v6.2.1  ready in 1606 ms

  ➜  Local:   http://localhost:3000/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
✘ [ERROR] Could not resolve "@tanstack/router-devtools-core"

    node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtools.js:2:43:
      2 │ ...TanStackRouterDevtoolsCore } from "@tanstack/router-devtools-core";
        ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@tanstack/router-devtools-core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

✘ [ERROR] Could not resolve "@tanstack/router-devtools-core"

    node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtoolsPanel.js:3:48:
      3 │ ...ackRouterDevtoolsPanelCore } from "@tanstack/router-devtools-core";
        ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@tanstack/router-devtools-core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

[Error: Build failed with 2 errors:
node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtools.js:2:43: ERROR: Could not resolve "@tanstack/router-devtools-core"
node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtoolsPanel.js:3:48: ERROR: Could not resolve "@tanstack/router-devtools-core"] {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v18.20.3

Your Example Website or App

https://stackblitz.com/github/tanstack/router/tree/main/examples/react/quickstart-file-based?file=package.json

Steps to Reproduce the Bug or Issue

  1. Goto the stackblitz url.
  2. Wait for the default build to fail.

Expected behavior

The build should succeed and the dev server should start.

Screenshots or Videos

Image

Platform

  • OS: macOS / Linux
  • Browser: Not applicable
  • Version: 1.114.3

Additional context

No response

Activity

  1. note11g commented on Mar 10, 2025

    @note11g

    i have same error.
    but difference with this issue description is not using react router setup.
    i have only react, vite, yarn dependencies.
    but produced same error.

    yarn 1.22.22, vite 6.2.1, darwin-arm64, node-v20.11.1,
    @tanstack/react-router-devtools@^1.114.4, @tanstack/react-router@^1.114.4, @tanstack/router-vite-plugin@^1.114.4

    (generation is succeeded. ✅ Processed routes in 67ms)

    ✘ [ERROR] Could not resolve "@tanstack/router-devtools-core"
    
        node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtools.js:2:43:
          2 │ import { TanStackRouterDevtoolsCore } from "@tanstack/router-devtools-core";
            ╵                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      You can mark the path "@tanstack/router-devtools-core" as external to exclude it from the bundle,
      which will remove this error and leave the unresolved path in the bundle.
    
    ✘ [ERROR] Could not resolve "@tanstack/router-devtools-core"
    
        node_modules/@tanstack/react-router-devtools/dist/esm/TanStackRouterDevtoolsPanel.js:3:48:
          3 │ import { TanStackRouterDevtoolsPanelCore } from "@tanstack/router-devtools-core";
            ╵                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      You can mark the path "@tanstack/router-devtools-core" as external to exclude it from the bundle,
      which will remove this error and leave the unresolved path in the bundle.
    
    
    
  2. note11g commented on Mar 10, 2025

    @note11g

    @jimjeffers
    I resolved with this solution.
    just add dev dependencies @tanstack/router-devtools-core, solid-js (tested on 1.114.6)

    but even i have little question. is really need solid js on dev-dependency?

    +I just tried using @tanstack/react-router-devtools instead of @tanstack/router-devtools, but it still depends on solidjs and core. I don’t understand why react-router-devtools needs to depend on solid-js. It seems like the dependency comes from core. Is this because of shared logic?

  3. julianklumpers commented on Mar 10, 2025

    @julianklumpers
    Contributor

    Same thing happens for me in Tanstack start after upgrading to version: 1.114.7 of the router and react-start
    Adding @tanstack/router-devtools-core, solid-js makes this error go away.

  4. birkskyum commented on Mar 10, 2025

    @birkskyum
    Member

    Is this resolved by react-router-devtools v1.114.12?

  5. graup commented on Mar 10, 2025

    @graup
    Contributor

    All the rotuer/core/devtools related import errors are resolved for me on 1.114.12 👍

  6. birkskyum commented on Mar 10, 2025

    @birkskyum
    Member
  7. jimjeffers commented on Mar 10, 2025

    @jimjeffers
    Author

    The inclusion of solid-js as a dip of a react project is insignificant as it's only a dev dependency correct?

  8. birkskyum commented on Mar 10, 2025

    @birkskyum
    Member

    It's actually a normal dependency, because we allow for opting into having devtools show in prod too if desired (e.g. tanstack.com does this). We have this conditional logic in place, to make sure it's tree-shaken otherwise:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions