Debug

In general, if you run into an issue with Vike, then we recommend reaching out.

That said, in some situations, you may want to dig into a problem yourself. For example, we may ask you to provide us a minimal reproduction but, sometimes, digging into Vike's source code can be faster than constructing a minimal reproduction. (And reading high-quality source code written by Open Source developers can be fun.)

Also, note the debug logs of Vike and Vite to easily gather insights.

Dig

The quickest way to dig into Vike is to inject a bunch of console.log() inside node_modules/vike/dist/**/*.js.

It may sound scary to dig into foreign source code, but it's sometimes quicker to find the root cause of your problem than treating Vike as a black box. Also:

  • It's more interesting. (Vike's source code is usually well-written and pleasurable to read.)
  • You may end up being able to do a Vike PR solving your problem (while helping the whole community).

We recommend digging not only into Vike, but also into other tools such as Vite (wich is very well-written).

Instead of:

$ git clone git@github.com:vikejs/vike
$ cd vike/vike/
$ pnpm install
$ pnpm run dev
$ cd ../../../my-app/
$ pnpm link ../vike/vike/

We recommend to:

  • Browse the source code of $ git clone git@github.com:vikejs/vike.
  • For an increased feedback loop, inject console.log() directly inside my-app/node_modules/vike/dist/**/*.js.

Vike debug logs

You can use Vike's debug logs to gather insights.

# Inspect Vike's routing
DEBUG=vike:routing npm run dev
# Inspect HTTP Streaming
DEBUG=vike:stream npm run dev
# Inspect errors
DEBUG=vike:error npm run dev
# Inspect logs
DEBUG=vike:log npm run dev
# Combination
DEBUG=vike:log,vike:error,vike:stream npm run dev

These debug logs allow you to understand how Vike thinks of your app. For example, to figure out why your app returns a 404, use vike:routing.

There are more debug logs but these aren't user-friendly as they are meant for Vike maintainers.

For more debug logs, add a comment at #249.

Vite debug logs

To enable Vite's debug logs, set the environment variable DEBUG to vite:*.

$ DEBUG=vite:* npm run dev