{"id":22572,"library":"vite-log-capture","title":"Vite Log Capture","description":"Vite plugin that captures console logs and HMR errors during development, allowing inspection and assertion of log output. Current stable version is 0.1.4 (released July 2024). Active development. Differentiators: integrates directly with Vite's HMR pipeline, captures both standard console logs and HMR-specific errors, and provides a simple API to retrieve captured logs for testing or debugging. Unlike generic log interceptors, it works seamlessly with Vite's dev server.","status":"active","version":"0.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/Posterior-AI/vite-log-capture","tags":["javascript","vite","plugin","log","capture","console","hmr","vite-plugin","typescript"],"install":[{"cmd":"npm install vite-log-capture","lang":"bash","label":"npm"},{"cmd":"yarn add vite-log-capture","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-log-capture","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required at version ^7.0.0","package":"vite","optional":false}],"imports":[{"note":"ESM-only module. CommonJS require() will error.","wrong":"const captureLogs = require('vite-log-capture')","symbol":"captureLogs","correct":"import { captureLogs } from 'vite-log-capture'"},{"note":"No subpath exports. Import from package root only.","wrong":"import { captureLogs, getCapturedLogs } from 'vite-log-capture/cjs'","symbol":"getCapturedLogs","correct":"import { getCapturedLogs } from 'vite-log-capture'"},{"note":"Named export, not default.","wrong":"import ViteLogCapture from 'vite-log-capture'","symbol":"ViteLogCapture","correct":"import { ViteLogCapture } from 'vite-log-capture'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { captureLogs, ViteLogCapture } from 'vite-log-capture';\n\nexport default defineConfig({\n  plugins: [ViteLogCapture()],\n});\n\n// In your application code\ncaptureLogs();\nconsole.log('test log');\nconsole.error('test error');\nconst logs = getCapturedLogs();\nconsole.log(logs); // [{ level: 'log', message: 'test log' }, { level: 'error', message: 'test error' }]","lang":"typescript","description":"Shows basic plugin setup in vite.config.ts, capturing console logs in application code, and retrieving captured logs."},"warnings":[{"fix":"Upgrade Vite to version 7.0.0 or later.","message":"Plugin only works with Vite 7.0.0 or above.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Call captureLogs() at the earliest point in your application, typically before any imports or module evaluation.","message":"captureLogs() must be called before any console logs you want to capture. Logs before the call are not captured.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"After retrieving logs, call clearCapturedLogs() to avoid accumulating duplicate entries.","message":"getCapturedLogs() returns a new array each time; it does not clear the internal buffer. To clear logs, use clearCapturedLogs().","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.4':26 '2024':29 'activ':30 'allow':15 'api':54 'assert':18 'captur':3,7,40,57,79 'consol':8,43,80 'current':22 'debug':62 'dev':73 'develop':14,31 'differenti':32 'direct':34 'error':12,49 'generic':64 'hmr':11,38,47,81 'hmr-specif':46 'inspect':16 'integr':33 'interceptor':66 'javascript':75 'juli':28 'log':2,9,20,44,58,65,78 'output':21 'pipelin':39 'plugin':5,77,84 'provid':51 'releas':27 'retriev':56 'seamless':69 'server':74 'simpl':53 'specif':48 'stabl':23 'standard':42 'test':60 'typescript':85 'unlik':63 'version':24 'vite':1,4,36,71,76,83 'vite-plugin':82 'work':68","created_at":"2026-04-27T17:05:52.927344+00:00","updated_at":"2026-04-27T17:05:52.927344+00:00","problems":[{"fix":"Run 'npm install vite@latest' to upgrade to Vite 7.0.0+.","cause":"Currently using Vite version below 7.0.0.","error":"Error: [vite-log-capture] Vite version must be ^7.0.0"},{"fix":"Use import statement instead: 'import { captureLogs } from \"vite-log-capture\"'","cause":"Trying to use require() to import the module instead of import.","error":"TypeError: require() of ES Module not supported"},{"fix":"Ensure import { captureLogs } from 'vite-log-capture' is at the top of the file and that the plugin is applied before using captureLogs.","cause":"captureLogs() was called before the import was evaluated (e.g., in a module where import order matters).","error":"Uncaught ReferenceError: captureLogs is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Posterior-AI/vite-log-capture","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-log-capture","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}