nocobase/nocobase · error · Error

No npm registry was provided for source publish.\nStart the

Error message

No npm registry was provided for source publish.\nStart the local source registry with `nb source registry start`, or pass `--npm-registry <url>` explicitly.

What it means

resolveSourcePublishRegistry determines which npm registry to publish source packages to. It first honors an explicitly provided registry URL, then tries the locally managed source registry. If neither exists and no registry is currently running, it throws with guidance to either start the local registry or pass --npm-registry.

Source

Thrown at packages/core/cli/src/lib/source-publish.ts:48

  return trimValue(value).replace(/[^A-Za-z0-9]+/g, '').slice(0, 16);
}

function normalizeSnapshotBaseVersion(baseVersion: string): string {
  return trimValue(baseVersion).replace(/(?:-snapshot\.\d{8}\.[A-Za-z0-9]+)+$/, '');
}

export async function resolveSourcePublishRegistry(explicitRegistry?: string): Promise<string> {
  const normalized = trimValue(explicitRegistry);
  if (normalized) {
    return normalized;
  }

  const info = await resolveSourceRegistryInfo();
  if (info.status === 'running') {
    return info.url;
  }

  throw new Error(
    [
      'No npm registry was provided for source publish.',
      'Start the local source registry with `nb source registry start`, or pass `--npm-registry <url>` explicitly.',
    ].join('\n'),
  );
}

export async function resolveGitSha(cwd?: string): Promise<string> {
  return await commandOutput('git', ['rev-parse', '--short', 'HEAD'], {
    cwd,
    errorName: 'git rev-parse',
  });
}

export async function readRootVersion(cwd?: string): Promise<string> {
  const root = resolveProjectCwd(cwd);
  const { readFile } = await import('node:fs/promises');
  const content = await readFile(path.join(root, 'lerna.json'), 'utf8');

View on GitHub (pinned to fa42722fef)

Solutions

  1. Start the local source registry: `nb source registry start`, then retry the publish.
  2. Pass the target registry explicitly: `nb source publish --npm-registry https://your-registry.example.com`.
  3. Check the registry daemon status/logs if you expected it to be running (`nb source registry status` or equivalent).

Example fix

// before
nb source publish
// after (pick one)
nb source registry start && nb source publish
nb source publish --npm-registry https://registry.example.com
Defensive patterns

Strategy: validation

Validate before calling

// precheck before nb source publish
const registry = process.env.npm_config_registry; // or explicit URL
const localRunning = await isSourceRegistryRunning(); // probe via CLI status
if (!registry && !localRunning) {
  throw new Error('start local registry (nb source registry start) or set --npm-registry');
}

Try / catch

try {
  await sourcePublish(options);
} catch (err) {
  if (err.message.includes('No npm registry was provided for source publish')) {
    // start the local registry or retry with { npmRegistry: url }
  }
}

Prevention

When it happens

Trigger: Running `nb source publish` without --npm-registry while the local source registry (`nb source registry start`) is not running and resolveSourceRegistryInfo() reports status !== 'running'.

Common situations: Fresh environment where the local registry was never started; the registry daemon crashed or was stopped; user forgot the --npm-registry flag when publishing to a remote registry.

Related errors


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