quasarframework/quasar · critical · Error
Refusing to remove the project root as build output
Error message
Refusing to remove the project root as build output
What it means
getBuildArtifactsCleanTarget refuses to delete the project root itself as build output. If the resolved target equals the project directory, or its realpath equals the project's realpath, removal would wipe the whole project and is blocked.
Source
Thrown at app-vite/lib/utils/remove-build-artifacts.js:82
const project = resolve(projectDir)
const effectiveProject = fse.realpathSync(project)
const home = fse.realpathSync(resolve(homedir()))
const target = resolve(projectDir, targetDir)
const effectiveTarget = getEffectivePath(target)
if (isFilesystemRoot(target) || isFilesystemRoot(effectiveTarget)) {
throw new Error('Refusing to remove a filesystem root as build output')
}
if (target === home || effectiveTarget === home) {
throw new Error(
'Refusing to remove the user home directory as build output'
)
}
if (target === project || effectiveTarget === effectiveProject) {
throw new Error('Refusing to remove the project root as build output')
}
if (
allowOutsideProject !== true &&
isContainedPath(effectiveProject, effectiveTarget) === false
) {
throw new Error(
'Build output directory must remain inside the project. Set build.allowOutsideProjectDistDir to true to explicitly allow an external directory.'
)
}
return { target, effectiveTarget }
}
export function removeBuildArtifacts(options) {
const { target, effectiveTarget } = getBuildArtifactsCleanTarget(options)
if (fse.pathExistsSync(target) === false) returnView on GitHub (pinned to 4841521b5f)
Solutions
- Set distDir to a dedicated subdirectory like 'dist'
- If you intended './dist', note '.' alone resolves to the project root — use 'dist'
- In scripts, assert target !== projectDir before invoking the cleaner
Example fix
// before distDir: '.' // after distDir: 'dist'
Defensive patterns
Strategy: validation
Validate before calling
const path = require('node:path')
const projectDir = path.resolve(process.cwd())
const target = path.resolve(projectDir, distDir)
if (target === projectDir) throw new Error('dist dir equals project root; use a subdirectory like dist') Try / catch
try {
await removeBuildArtifacts(opts)
} catch (err) {
if (err.message === 'Refusing to remove the project root as build output') {
// fix distDir (use 'dist'), never override
} else throw err
} Prevention
- Use a dedicated subdirectory ('dist') for build output, never '.'
- Keep targetDir and projectDir parameters distinct in custom scripts
- Compare resolved paths before any rm -rf style operation in your own tooling
When it happens
Trigger: Setting the build output directory to '.' or the projectDir itself (e.g. distDir: '.', or targetDir: projectDir in programmatic use), so resolve(projectDir, targetDir) === project.
Common situations: distDir: '.' in quasar.config.js; confusing projectDir/targetDir parameters in a custom script; empty string or './' collapsing to the project root after resolution.
Related errors
- Refusing to remove a filesystem root as build output
- Refusing to remove the user home directory as build output
- Build output directory must remain inside the project. Set b
- Could not resolve an existing ancestor for "${target}"
- Build output directory must be a non-empty path
AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30).
Data as JSON: /api/errors/f00f1b7366f165d3.
Report an issue: GitHub.