{"record":{"id":"a4a50e7516ab928e","repo":"nodejs/node","slug":"you-cannot-publish-over-the-previously-published-v","errorCode":null,"errorMessage":"You cannot publish over the previously published versions: ${manifest.version}.","messagePattern":"You cannot publish over the previously published versions: (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/publish.js","lineNumber":176,"sourceCode":"      )\n    }\n\n    if (noCreds) {\n      const msg = `This command requires you to be logged in to ${outputRegistry}`\n      if (dryRun) {\n        log.warn(this.#command, `${msg} (dry-run)`)\n      } else {\n        throw Object.assign(new Error(msg), { code: 'ENEEDAUTH' })\n      }\n    }\n\n    if (!force) {\n      const { highestVersion, versions } = await this.#registryVersions(resolved, registry)\n      /* eslint-disable-next-line max-len */\n      const highestVersionIsGreater = !!highestVersion && semver.gte(highestVersion, manifest.version)\n\n      if (versions.includes(manifest.version)) {\n        throw new Error(`You cannot publish over the previously published versions: ${manifest.version}.`)\n      }\n\n      if (highestVersionIsGreater && isDefaultTag) {\n        throw new Error(`Cannot implicitly apply the \"latest\" tag because previously published version ${highestVersion} is higher than the new version ${manifest.version}. You must specify a tag using --tag.`)\n      }\n    }\n\n    const access = opts.access === null ? 'default' : opts.access\n    const verb = this.isStage ? 'Staging' : 'Publishing'\n    let msg = `${verb} to ${outputRegistry} with tag ${defaultTag} and ${access} access`\n    if (dryRun) {\n      msg = `${msg} (dry-run)`\n    }\n\n    log.notice('', msg)\n\n    let stageId\n    if (!dryRun) {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/publish.js#L158-L194","documentation":"Thrown by `npm publish` when the package version being published already exists in the registry's version list and `--force` is not set. The registry rejects republishing an immutable version, so npm fails fast before the network call with a clear message.","triggerScenarios":"Running `npm publish` for a version that `#registryVersions` already returned in `versions` (i.e. the registry's `/<pkg>` document lists `manifest.version`), with `force` disabled.","commonSituations":"Re-running a CI publish job after it partially succeeded; forgetting to bump `version` in package.json after a successful publish; local publish against a local/cached registry that already holds the version.","solutions":["Bump the version in package.json (`npm version patch|minor|major`) before publishing.","If the prior publish genuinely failed and left no artifact, unpublish the version first (within the time window), then republish.","Use a different registry or scope, or `--force` only if you understand the registry will still reject immutable versions.","Verify you are targeting the intended registry (`--registry`) and not accidentally republishing to the public one."],"exampleFix":"// before\nnpm publish   // 1.2.3 already on registry\n// after\nnpm version patch && npm publish","handlingStrategy":"validation","validationCode":"const semver = require('semver')\nasync function assertVersion unpublished(pkgName, version, registry) {\n  const res = await fetch(`${registry}/${pkgName}`, { headers: { accept: 'application/json' } })\n  const data = await res.json()\n  const published = Object.keys(data.versions || {})\n  if (published.includes(version)) {\n    throw new Error(`${pkgName}@${version} is already published; bump the version.`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await npmPublish()\n} catch (e) {\n  if (/cannot publish over the previously published/i.test(e.message)) {\n    await run('npm version patch')\n    return npmPublish()\n  }\n  throw e\n}","preventionTips":["Bump the version automatically in CI after every successful publish.","Run `npm view <pkg> versions --json` in a pre-publish check.","Make publish jobs idempotent or guarded so re-runs do not republish."],"tags":["publish","version-conflict","registry","npm-cli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}