quasarframework/quasar · error

Could not generate ${assetRelativePath}.

Error message

Could not generate ${assetRelativePath}.

What it means

When copying a scaffold template from the @quasar/app-vite package into the project fails, `quasar new` logs the underlying fs error and warns 'Could not generate <path>' with a FAIL label. The command continues with other requested files and does not exit non-zero for this file. It indicates the template source or destination was unreadable/unwritable.

Source

Thrown at app-vite/lib/cmd/new.js:128

  showError(`Invalid asset format: ${format} (valid values: js|ts)`)
}

function createFile({ targetFile, ext, reference }) {
  const assetRelativePath = relative(appPaths.appDir, targetFile)

  if (fs.existsSync(targetFile)) {
    warn(`${assetRelativePath} already exists.`, 'SKIPPED')
    console.log()
    return
  }

  fse.ensureDir(dirname(targetFile))
  const templatePath = join('templates/app', format, `${type}.${ext}`)

  fse.copy(appPaths.resolve.cli(templatePath), targetFile, err => {
    if (err) {
      console.warn(err)
      warn(`Could not generate ${assetRelativePath}.`, 'FAIL')
      return
    }

    log(`Generated ${type}: ${assetRelativePath}`)
    if (reference) {
      log(`Make sure to reference it in ${reference}`)
    }
    log()
  })
}

async function getAsset(assetType) {
  if (assetType === 'page') {
    return {
      relativePath: 'src/pages',
      ext: 'vue',
      reference: `src/router/routes.${format}`
    }

View on GitHub (pinned to 4841521b5f)

Solutions

  1. Reinstall dependencies (`rm -rf node_modules && pnpm install`) to restore the CLI templates.
  2. Check write permissions on the target directory (and that you don't need sudo/a different owner).
  3. Re-run the `quasar new` command for the failed file and check the console.warn output above the warning for the exact fs error.

Example fix

// before (permission denied on src/pages)
$ quasar new p Login  -> Could not generate src/pages/Login.vue
// after
$ sudo chown -R $(whoami) . && pnpm install && quasar new p Login
Defensive patterns

Strategy: try-catch

Validate before calling

import { accessSync, constants } from 'node:fs';
try { accessSync('src/pages', constants.W_OK); } catch { console.error('no write permission on src/pages'); }

Try / catch

// the CLI already catches; wrap programmatic invocations of the CLI instead
try {
  execSync('quasar new p Login', { stdio: 'inherit' });
} catch (err) {
  if (err.stderr?.includes('Could not generate')) reinstallTemplates();
}

Prevention

When it happens

Trigger: fse.copy(appPaths.resolve.cli(templatePath), targetFile) invoking its error callback — e.g. the template file is missing from the installed CLI package, or the destination directory/file cannot be written (permissions, read-only fs) (new.js:125-130).

Common situations: Corrupted or partially pruned node_modules/@quasar/app-vite install; running inside a read-only container or without write permission to the project; antivirus locking files on Windows; project dir owned by another user (sudo mismatch).

Related errors


AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30). Data as JSON: /api/errors/87612e2220dcb430. Report an issue: GitHub.