quasarframework/quasar · error · Error
Failed to load Quasar import map
Error message
Failed to load Quasar import map
What it means
The Quasar Vite plugin caches an import map read from `<quasar package>/dist/transforms/import-map.json`, which maps named Quasar exports to their build files. If reading/parsing that file fails, loadQuasarImportMap() rethrows 'Failed to load Quasar import map' with the underlying error as `cause`. This runs at configResolved time, so dev server startup or build fails immediately.
Source
Thrown at vite-plugin/src/js-transform.js:16
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { parseSync } from 'vite'
import { quasarPath } from './quasar-path.js'
let quasarImportMap
export function loadQuasarImportMap() {
if (quasarImportMap !== void 0) return
try {
quasarImportMap = JSON.parse(
readFileSync(join(quasarPath, 'dist/transforms/import-map.json'), 'utf8')
)
} catch (err) {
throw new Error('Failed to load Quasar import map', { cause: err })
}
}
const importQuasarRegex = /import\s*\{([^}]*)\}\s*from\s*(['"])quasar\2;?/g
const stripCommentsRegex = /\/\*[\s\S]*?\*\/|\/\/.*/g
/**
* Textual pre-filter for imports (or exports) from the "quasar" package
* that survived the transformations — static, re-export or dynamic form.
* Can false-positive on string content (e.g. documentation snippets),
* so a match must be confirmed by hasResidualQuasarImports().
*/
export const residualQuasarImportRegex =
/from\s*(['"])quasar\1|import\s*\(\s*(['"])quasar\2\s*\)/
const dynamicResidualRegex = /import\s*\(\s*(['"])quasar\1\s*\)/
const staticQuasarImportNodeTypes = new Set([View on GitHub (pinned to 4841521b5f)
Solutions
- Clean reinstall: remove node_modules (and quasar's lockfile entry) and run `pnpm install` / `npm ci` again.
- Confirm `node_modules/quasar/dist/transforms/import-map.json` exists and parses; rebuild the quasar package if you're linking a local checkout.
- Align versions: use matching quasar and @quasar/vite-plugin releases (check both changelogs for breaking transform-file changes).
- Read `err.cause` from the stack trace to distinguish ENOENT (missing file) from a JSON parse error (corrupt content).
Example fix
# before, when linking local quasar for development
devDependencies: { quasar: 'file:../ui' } # dist never built
# after: build it first
pnpm --dir ../ui build && pnpm install Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'node:fs'
const mapPath = join(quasarPath, 'dist/transforms/import-map.json')
if (!existsSync(mapPath)) {
throw new Error(`quasar package incomplete: ${mapPath} missing; run a clean reinstall or build quasar dist`)
} Try / catch
try {
startViteDevServer()
} catch (err) {
if (err.message === 'Failed to load Quasar import map') {
console.error('Reinstall quasar (broken dist) or rebuild your local quasar checkout', err.cause)
process.exit(1)
}
throw err
} Prevention
- When linking a local quasar checkout, always build its dist before starting the dev server.
- Pin matching versions of quasar and @quasar/vite-plugin.
- Verify import-map.json exists after every dependency install in CI.
- Inspect err.cause to distinguish a missing file from corrupt JSON.
When it happens
Trigger: vite dev/build startup when `quasar` resolves but its dist/transforms/import-map.json is missing, unreadable, or invalid JSON — typically a broken/partial quasar package install or an incompatible quasar package version.
Common situations: Interrupted installs leaving a truncated quasar dist; stale CI dependency caches; monorepo linking quirks where `quasar` resolves to a source checkout without a built dist; version drift between quasar and @quasar/vite-plugin.
Related errors
- Failed to load Quasar auto-import data
- Unknown import from Quasar: ${importName}
- [Quasar] In your Vite config file, please add the Quasar plu
- [Quasar] "${id}" contains an import from "quasar" that could
AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30).
Data as JSON: /api/errors/22316e51b5a00040.
Report an issue: GitHub.