{"record":{"id":"f5be972be77352fb","repo":"vitest-dev/vitest","slug":"vitest-received-browser-flag-but-no-project-had","errorCode":null,"errorMessage":"Vitest received --browser flag, but no project had a browser configuration.","messagePattern":"Vitest received --browser flag, but no project had a browser configuration\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/core.ts","lineNumber":416,"sourceCode":"        injectTestProjects: this.injectTestProject,\n        defineCacheKeyGenerator: callback => this._fsCache.defineCacheKeyGenerator(callback),\n        /**\n         * @deprecated Use `defineCacheKeyGenerator` instead.\n         */\n        experimental_defineCacheKeyGenerator: (callback) => {\n          if (!this._warnedExperimentalCacheKeyGenerator) {\n            this._warnedExperimentalCacheKeyGenerator = true\n            this.logger.deprecate('`experimental_defineCacheKeyGenerator` is deprecated. Use `defineCacheKeyGenerator` instead.')\n          }\n          this._fsCache.defineCacheKeyGenerator(callback)\n        },\n      }))\n    }))\n\n    if (resolved.cliOptions.browser?.enabled) {\n      const browserProjects = this.projects.filter(p => p.config.browser.enabled)\n      if (!browserProjects.length) {\n        throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`)\n      }\n    }\n    if (!this.projects.length) {\n      const filter = toArray(resolved.project).join('\", \"')\n      if (filter) {\n        throw new Error(`No projects matched the filter \"${filter}\".`)\n      }\n      else {\n        let error = `Vitest wasn't able to resolve any project.`\n        if (resolved.browser.enabled && !resolved.browser.instances?.length) {\n          error += ` Please, check that you specified the \"browser.instances\" option.`\n        }\n        throw new Error(error)\n      }\n    }\n\n    if (!this.coreWorkspaceProject) {\n      this.coreWorkspaceProject = TestProject._createBasicProject(this)","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/core.ts#L398-L434","documentation":"After resolving all workspace projects, Vitest checks whether the CLI requested browser mode (`resolved.cliOptions.browser.enabled`). If none of the resolved projects has `config.browser.enabled === true`, the global flag has nothing to attach to and Vitest aborts instead of silently running node tests.","triggerScenarios":"Passing `--browser` on the CLI when no project config sets `browser.enabled: true`; running `vitest --browser` in a fresh repo without browser setup.","commonSituations":"A script that always passes `--browser` reused on a non-browser project; partial migration where browser config lives in a workspace file that is not being loaded.","solutions":["Add `test.browser.enabled: true` (and at least one `instances` entry) to the project you intend to run in the browser.","Drop `--browser` from the CLI/script when running node-only projects.","Confirm your workspace config is actually being picked up (check `vitest --showConfig` or the resolved projects list)."],"exampleFix":"// before\nvitest --browser   # no project has browser.enabled\n// after\n// vitest.config.ts\nexport default defineConfig({\n  test: { browser: { enabled: true, instances: [{ browser: 'chromium' }] } },\n})","handlingStrategy":"validation","validationCode":"const cliBrowser = process.argv.includes('--browser')\nconst hasBrowserProject = (workspace: any[]) => workspace.some(p => p?.test?.browser?.enabled)\nif (cliBrowser && !hasBrowserProject(projects)) {\n  throw new Error('--browser was passed but no project enables browser mode.')\n}","typeGuard":"function anyProjectEnablesBrowser(projects: any[]): boolean {\n  return projects.some(p => p?.test?.browser?.enabled === true)\n}","tryCatchPattern":null,"preventionTips":["Gate the `--browser` flag in scripts that are only used by browser-enabled repos.","Run `vitest list` after workspace changes to confirm the browser project resolves."],"tags":["cli","browser","workspace","config"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}