Skip to content

Only show error backtrace when VITE_BACKTRACE=1 #20055

@typed-sigterm

Description

@typed-sigterm

Description

Just moved a file... the terminal at the bottom of VS Code suddenly exploded with a long error:

10:31:57 [vite] Internal server error: Failed to resolve import "../utility" from "src/providers/auth.ts". Does the file exist?
  Plugin: vite:import-analysis
  File: .../src/providers/auth.ts:2:21
  1  |  import { supa } from "../utility";
     |                        ^
  2  |  const authProvider = {
  3  |    async login({ email, password, providerName }) {
      at TransformPluginContext._formatLog (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42499:41)
      at TransformPluginContext.error (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42496:16)
      at normalizeUrl (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:40475:23)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:40594:37
      at async Promise.all (index 0)
      at async TransformPluginContext.transform (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:40521:7)
      at async EnvironmentPluginContainer.transform (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42294:18)
      at async loadAndTransform (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:35735:27)   
      at async viteTransformMiddleware (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:37250:24)

It's filled with the most secondary information, while the most important information needs to be unfolded to be seen.

Suggested solution

Like rust:

thread 'main' panicked at src/main.rs:2:5:
some error message...
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
10:31:57 [vite] Internal server error: Failed to resolve import "../utility" from "src/providers/auth.ts". Does the file exist?
  Note: run with `VITE_BACKTRACE=1` environment variable to display a backtrace

Alternative

No response

Additional context

No response

Validations

  • Follow our Code of Conduct
    Read the docs.
    Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @sapphi-red@typed-sigterm

      Issue actions

        Only show error backtrace when `VITE_BACKTRACE=1` · Issue #20055 · vitejs/vite