Skip to content
Vitest 3
Main Navigation Guide & APIConfigBrowser ModeAdvanced API
3.2.0
2.1.9
1.6.1
0.34.6

English

简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
한국어
Italiano
Polski
Türkçe
čeština
magyar

English

简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
한국어
Italiano
Polski
Türkçe
čeština
magyar

Appearance

Sidebar Navigation

Introduction

Why Vitest

Getting Started

Features

Config Reference

API

Test API Reference

Mock Functions

Vi Utility

Expect

ExpectTypeOf

Assert

AssertType

Guides

CLI

Test Filtering

Test Projects

Reporters

Coverage

Snapshot

Mocking

Parallelism

Testing Types

Vitest UI

In-Source Testing

Test Context

Test Annotations

Environment

Extending Matchers

IDE Integration

Debugging

Common Errors

Migration Guide

Migrating to Vitest 3.0

Migrating from Jest

Performance

Profiling Test Performance

Improving Performance

Browser Mode

Node API Reference

Comparisons

On this page

Common Errors ​

Cannot find module './relative-path' ​

If you receive an error that module cannot be found, it might mean several different things:

    1. You misspelled the path. Make sure the path is correct.
    1. It's possible that you rely on baseUrl in your tsconfig.json. Vite doesn't take into account tsconfig.json by default, so you might need to install vite-tsconfig-paths yourself, if you rely on this behaviour.
ts
import { defineConfig } from 'vitest/config';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  plugins: [tsconfigPaths()],
});

Or rewrite your path to not be relative to root:

diff
- import helpers from 'src/helpers'
+ import helpers from '../src/helpers'
    1. Make sure you don't have relative aliases. Vite treats them as relative to the file where the import is instead of the root.
ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    alias: {
      '@/': './src/', 
      '@/': new URL('./src/', import.meta.url).pathname, 
    },
  },
});

Failed to terminate worker ​

This error can happen when NodeJS's fetch is used with default pool: 'threads'. This issue is tracked on issue Timeout abort can leave process(es) running in the background #3077.

As work-around you can switch to pool: 'forks' or pool: 'vmForks'.

ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    pool: 'forks',
  },
});
bash
vitest --pool=forks

Segfaults and native code errors ​

Running native NodeJS modules in pool: 'threads' can run into cryptic errors coming from the native code.

  • Segmentation fault (core dumped)
  • thread '<unnamed>' panicked at 'assertion failed
  • Abort trap: 6
  • internal error: entered unreachable code

In these cases the native module is likely not built to be multi-thread safe. As work-around, you can switch to pool: 'forks' which runs the test cases in multiple node:child_process instead of multiple node:worker_threads.

ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    pool: 'forks',
  },
});
bash
vitest --pool=forks
Pager
Previous pageDebugging
Next pageMigration Guide

Released under the MIT License.

Copyright (c) 2021-Present Vitest Team

https://vitest.dev/guide/common-errors

Released under the MIT License.

Copyright (c) 2021-Present Vitest Team