nocobase/nocobase · error

Cannot determine @nocobase/devtools version because dependen

Error message

Cannot determine @nocobase/devtools version because dependencies["@nocobase/app"] is missing.

What it means

In an npm-sourced local app, ensureNpmSourceDevDependencies pins `@nocobase/devtools` in devDependencies to the same version as `@nocobase/app`. If package.json has no devtools version AND no dependencies['@nocobase/app'], the target version cannot be determined, so this explicit Error is thrown.

Source

Thrown at packages/core/cli/src/lib/app-managed-resources.ts:579

    onStartTask?: (message: string) => void;
    onSucceedTask?: (message: string) => void;
    onFailTask?: (message: string) => void;
  },
): Promise<void> {
  if (runtime.source !== 'npm') {
    return;
  }

  let taskStarted = false;
  try {
    const packageJson = await readPackageJson(runtime.projectRoot);
    const appVersion = getStringDependency(packageJson, 'dependencies', '@nocobase/app');
    const devtoolsVersion = getStringDependency(packageJson, 'devDependencies', '@nocobase/devtools');
    let updatedPackageJson = false;

    if (!devtoolsVersion) {
      if (!appVersion) {
        throw new Error(
          'Cannot determine @nocobase/devtools version because dependencies["@nocobase/app"] is missing.',
        );
      }
      const devDependencies = ensureDevDependencies(packageJson);
      devDependencies['@nocobase/devtools'] = appVersion;
      updatedPackageJson = true;
      await writeFile(
        path.join(runtime.projectRoot, 'package.json'),
        `${JSON.stringify(packageJson, null, 2)}\n`,
        'utf-8',
      );
    }

    const needsInstall = updatedPackageJson || !hasNpmSourceDevtools(runtime.projectRoot);
    if (!needsInstall) {
      return;
    }

View on GitHub (pinned to fa42722fef)

Solutions

  1. Add "@nocobase/app" to dependencies in the project's package.json with the intended version.
  2. Alternatively add "@nocobase/devtools" to devDependencies explicitly so no version inference is needed.
  3. Recreate the project via the official scaffold to get a correct package.json.
  4. Ensure you are running the command in the intended projectRoot (the package.json read there may be the wrong one).

Example fix

// before (package.json)
{
  "dependencies": {}
}
// after
{
  "dependencies": {
    "@nocobase/app": "1.x.x"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

const pkg = JSON.parse(await fs.readFile(path.join(projectRoot, 'package.json'), 'utf-8'));
if (!pkg.dependencies?.['@nocobase/app'] && !pkg.devDependencies?.['@nocobase/devtools']) {
  throw new Error('Add @nocobase/app to dependencies or @nocobase/devtools to devDependencies first.');
}

Type guard

function hasDevtoolsVersion(pkg: unknown): pkg is { devDependencies: { '@nocobase/devtools': string } } {
  return typeof pkg === 'object' && pkg !== null &&
    typeof (pkg as any).devDependencies?.['@nocobase/devtools'] === 'string';
}

Try / catch

try {
  await ensureNpmSourceDevDependencies(runtime, opts);
} catch (e) {
  if (e instanceof Error && e.message.includes('@nocobase/app')) {
    // fix package.json, then retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling ensureNpmSourceDevDependencies (via `run`) on a project whose package.json lacks both devDependencies['@nocobase/devtools'] and dependencies['@nocobase/app'].

Common situations: A hand-edited or pruned package.json that removed @nocobase/app; initializing devtools tooling in a project that was not created from the NocoBase app template; dependency renamed or moved to another section.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01). Data as JSON: /api/errors/2375597ffb8e701a. Report an issue: GitHub.