[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

docs: document `ssr.resolve.conditions` for custom package conditions (#9392)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

authored by

Copilot
copilot-swe-agent[bot]
hi-ogawa
Hiroshi Ogawa
Claude Opus 4.5
and committed by
GitHub
(Jan 8, 2026, 10:22 AM +0100) 41d82762 fca1c95b

+47
+47
docs/guide/common-errors.md
··· 64 64 ``` 65 65 ::: 66 66 67 + ## Custom package conditions are not resolved 68 + 69 + If you are using custom conditions in your `package.json` [exports](https://nodejs.org/api/packages.html#package-entry-points) or [subpath imports](https://nodejs.org/api/packages.html#subpath-imports), you may find that Vitest does not respect these conditions by default. 70 + 71 + For example, if you have the following in your `package.json`: 72 + 73 + ```json 74 + { 75 + "exports": { 76 + ".": { 77 + "custom": "./lib/custom.js", 78 + "import": "./lib/index.js" 79 + } 80 + }, 81 + "imports": { 82 + "#internal": { 83 + "custom": "./src/internal.js", 84 + "default": "./lib/internal.js" 85 + } 86 + } 87 + } 88 + ``` 89 + 90 + By default, Vitest will only use the `import` and `default` conditions. To make Vitest respect custom conditions, you need to configure [`ssr.resolve.conditions`](https://vite.dev/config/ssr-options#ssr-resolve-conditions) in your Vitest config: 91 + 92 + ```ts [vitest.config.js] 93 + import { defineConfig } from 'vitest/config' 94 + 95 + export default defineConfig({ 96 + ssr: { 97 + resolve: { 98 + conditions: ['custom', 'import', 'default'], 99 + }, 100 + }, 101 + }) 102 + ``` 103 + 104 + ::: tip Why `ssr.resolve.conditions` and not `resolve.conditions`? 105 + Vitest follows Vite's configuration convention: 106 + - [`resolve.conditions`](https://vite.dev/config/shared-options#resolve-conditions) applies to Vite's `client` environment, which corresponds to Vitest's browser mode, jsdom, happy-dom, or custom environments with `viteEnvironment: 'client'`. 107 + - [`ssr.resolve.conditions`](https://vite.dev/config/ssr-options#ssr-resolve-conditions) applies to Vite's `ssr` environment, which corresponds to Vitest's node environment or custom environments with `viteEnvironment: 'ssr'`. 108 + 109 + Since Vitest defaults to the `node` environment (which uses `viteEnvironment: 'ssr'`), module resolution uses `ssr.resolve.conditions`. This applies to both package exports and subpath imports. 110 + 111 + You can learn more about Vite environments and Vitest environments in [`environment`](/config/environment). 112 + ::: 113 + 67 114 ## Segfaults and native code errors 68 115 69 116 Running [native NodeJS modules](https://nodejs.org/api/addons.html) in `pool: 'threads'` can run into cryptic errors coming from the native code.