quasarframework/quasar · warning

extendPackageJson() - "${extPkg}" is a folder instead of fil

Error message

extendPackageJson() - "${extPkg}" is a folder instead of file. Skipping...

What it means

extendPackageJson() resolves its string argument to a file; if fs.lstatSync reports the path is a directory, it warns and skips the merge. A folder cannot be parsed as a JSON fragment, so the extension's package.json additions are not applied.

Source

Thrown at app-vite/lib/app-extension/api-classes/InstallAPI.js:152

   * If specifying existing props, it will override them.
   *
   * @param {object|string} extPkg - Object to extend with or relative path to a JSON file
   */
  extendPackageJson(extPkg) {
    if (!extPkg) return

    if (typeof extPkg === 'string') {
      const dir = getCallerPath(1)
      const source = path.resolve(dir, extPkg)

      if (!fs.existsSync(source)) {
        this.logger.warn(
          `extendPackageJson() - cannot locate ${extPkg}. Skipping...`
        )
        return
      }
      if (fs.lstatSync(source).isDirectory()) {
        this.logger.warn(
          `extendPackageJson() - "${extPkg}" is a folder instead of file. Skipping...`
        )
        return
      }

      try {
        extPkg = JSON.parse(fs.readFileSync(source, 'utf8'))
      } catch {
        this.logger.warn(
          `extendPackageJson() - "${extPkg}" is malformed. Exiting...`
        )
        warn()
        process.exit(1)
      }
    }

    if (Object(extPkg) !== extPkg || Object.keys(extPkg).length === 0) return

View on GitHub (pinned to 4841521b5f)

Solutions

  1. Point extendPackageJson at the actual JSON file, not its folder
  2. Verify the path with fs.statSync(...).isFile() during development
  3. Pass a function to extendPackageJson to avoid file path resolution entirely

Example fix

// before
api.extendPackageJson('./')
// after
api.extendPackageJson('./package-ext.json')
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
const stat = fs.statSync(source)
if (!stat.isFile()) {
  throw new Error(`extendPackageJson expects a file, got a ${stat.isDirectory() ? 'directory' : 'other'}: ${source}`)
}

Prevention

When it happens

Trigger: Calling api.extendPackageJson('./some-folder') where the argument points to a directory instead of a .json file.

Common situations: Passing the extension root folder by mistake; a path without extension where both file.json and a directory exist and the directory wins; refactoring that moved the JSON into a folder but kept passing the old-style path.

Related errors


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