You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you receive an error that module cannot be found, it might mean several different things:
6
+
7
+
-1. You misspelled the path. Make sure the path is correct.
8
+
9
+
-2. It's possible that your 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`](https://www.npmjs.com/package/vite-tsconfig-paths) yourself, if you rely on this behaviour.
10
+
11
+
```ts
12
+
import { defineConfig } from'vitest/config'
13
+
importtsconfigPathsfrom'vite-tsconfig-paths'
14
+
15
+
exportdefaultdefineConfig({
16
+
plugins: [tsconfigPaths()]
17
+
})
18
+
```
19
+
20
+
Or rewrite your path to not be relative to root:
21
+
22
+
```diff
23
+
- import helpers from 'src/helpers'
24
+
+ import helpers from '../src/helpers'
25
+
```
26
+
27
+
-3. Make sure you don't have relative [aliases](/config/#alias). Vite treats them as relative to the file where the import is instead of the root.
28
+
29
+
```diff
30
+
import { defineConfig } from 'vitest/config'
31
+
32
+
export default defineConfig({
33
+
test: {
34
+
alias: {
35
+
- '@/': './src/',
36
+
+ '@/': new URL('./src/', import.meta.url).pathname,
+'\n\n- If you rely on tsconfig.json to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.'
250
+
+'\n - Make sure you don\'t have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors',
0 commit comments