vuejs/vue-cli · error · Error

Configuration Error: Do not set output directory to projec

Error message


Configuration Error: Do not set output directory to project root.

What it means

validateWebpackConfig guards against the resolved output.path being equal to the project root (api.service.context). Writing build artifacts into the project root would overwrite source files, so this is rejected outright.

Source

Thrown at packages/@vue/cli-service/lib/util/validateWebpackConfig.js:25

  const singleConfig = Array.isArray(webpackConfig)
    ? webpackConfig[0]
    : webpackConfig

  const actualTargetDir = singleConfig.output.path

  if (actualTargetDir !== api.resolve(options.outputDir)) {
    // user directly modifies output.path in configureWebpack or chainWebpack.
    // this is not supported because there's no way for us to give copy
    // plugin the correct value this way.
    throw new Error(
      `\n\nConfiguration Error: ` +
      `Avoid modifying webpack output.path directly. ` +
      `Use the "outputDir" option instead.\n`
    )
  }

  if (actualTargetDir === api.service.context) {
    throw new Error(
      `\n\nConfiguration Error: ` +
      `Do not set output directory to project root.\n`
    )
  }

  if (target === 'app' && singleConfig.output.publicPath !== options.publicPath) {
    throw new Error(
      `\n\nConfiguration Error: ` +
      `Avoid modifying webpack output.publicPath directly. ` +
      `Use the "publicPath" option instead.\n`
    )
  }
}

View on GitHub (pinned to 7eb93c169c)

Solutions

  1. Set outputDir to a real subfolder, e.g. `'dist'`.
  2. Avoid empty-string or `.`/`./` values for outputDir.

Example fix

// vue.config.js — before
module.exports = { outputDir: '' }
// after
module.exports = { outputDir: 'dist' }
Defensive patterns

Strategy: validation

Validate before calling

const path = require('path')
const resolved = path.resolve(process.cwd(), options.outputDir || 'dist')
if (resolved === path.resolve(process.cwd())) {
  throw new Error('outputDir resolves to project root; choose a subfolder like "dist"')
}

Prevention

When it happens

Trigger: Setting `outputDir` to the project root — e.g. `outputDir: ''`, `outputDir: '.'`, or `outputDir: './'` — so that `api.resolve(outputDir)` resolves to the cwd.

Common situations: Empty/relative outputDir misconfiguration; attempting to output at repo root.

Related errors


AI-assisted analysis of vuejs/vue-cli@7eb93c169c (2026-08-13). Data as JSON: /api/errors/64d605b8eade1b1b. Report an issue: GitHub.