Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ title: Debugging | Introduction
description: Learn a few debugging tips to streamline your journey with Qwik.
contributors:
- gioboa
updated_at: '2025-08-08T00:00:00Z'
created_at: '2025-08-08T00:00:00Z'
- KyeongJooni
updated_at: '2025-12-13T00:00:00Z'
created_at: '2025-12-13T00:00:00Z'
---
# Debugging

Expand All @@ -14,8 +15,85 @@ During development, you can quickly access the source code of any element on a w
click on whatever you're curious about, and Qwik will immediately open your source code right on top of that element.
Seriously, any component, link, header - you name it, you can peek at its code.

Qwik tries to guess what code editor you like to use.
If it guesses wrong, no biggie! Just give Qwik a hint by setting the `LAUNCH_EDITOR` environment variable.
For example, if you're on a Mac and use VS Code, you'd type `export LAUNCH_EDITOR=code` in your terminal.

Under the hood [launch-editor library](https://github.com/yyx990803/launch-editor/tree/master) is used, here are the [supported editors](https://github.com/yyx990803/launch-editor/tree/master?tab=readme-ov-file#supported-editors)

## Finding leftover `console.log` statements

When working on larger codebases, you might occasionally leave `console.log` statements in your code unintentionally. These can clutter your terminal output, and it's often difficult to identify which file and line number produced each log message.

### Using ESLint rules

The recommended approach is to configure ESLint to prevent `console.log` statements from being committed:

```js
// eslint.config.js
export default [
{
rules: {
'no-console': ['error', { allow: ['warn', 'error'] }],
},
},
];
```

This will catch `console.log` statements during development, preventing them from being committed.

### Using IDE search

Most IDEs provide powerful search functionality to find all occurrences of `console.log` across your codebase:
- **VS Code**: Press `Ctrl+Shift+F` (or `Cmd+Shift+F` on Mac) and search for `console\.log`
- **Enable regex mode** to match only exact `console.log` calls and not `console.error` or `console.warn`

This approach is simple but requires manual review of each occurrence to determine if it's intentional or leftover debug code.

### Using stack traces (temporary debugging)

If you need to identify existing leftover console.logs in a codebase that's already cluttered, you can temporarily override `console.log` to include stack traces.

#### In client-side components

You can override `console.log` in your component code:

```tsx
// root.tsx or layout.tsx
export default component$(() => {
// Override console.log to include stack traces
useVisibleTask$(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't like this approach with visible tasks because you need to remember and remove them too.eslint seems to be the best way to tackle the problem.

Copy link
Author

@KyeongJooni KyeongJooni Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @gioboa!
Thanks for the feedback! I've moved ESLint to the top as the primary recommendation. I kept the stack trace approach at the bottom since the original issue mentioned it can be helpful for identifying existing logs in codebases that are already cluttered. Added a note to remove it after debugging. Happy to adjust further if needed!

const originalLog = console.log;
console.log = (...args: any[]) => {
const stack = new Error()
.stack?.split('\n')
.filter((i) => !/^.*(\.vite|\.main\.jsx|node_modules).*/.test(i));
originalLog(stack, ...args);
};
});

return (
// your component JSX
);
});
```

#### In server-side entry files

For entry files like `entry.express.tsx`, `entry.dev.tsx`, or `entry.preview.tsx`, you can override `console.log` at the module level:

```tsx
// entry.express.tsx or entry.dev.tsx or entry.preview.tsx

// Override console.log at the top level
const originalLog = console.log;
console.log = (...args: any[]) => {
const stack = new Error()
.stack?.split('\n')
.filter((i) => !/^.*(node_modules|internal).*/.test(i));
originalLog(stack, ...args);
};

// Rest of your entry file code...
```

> **Note:** Remember to remove these overrides after debugging. The filter regex should be adjusted based on your specific build setup.