{"record":{"id":"d5c385c067ad93a9","repo":"nodejs/node","slug":"cannot-implicitly-apply-the-latest-tag-because-p","errorCode":null,"errorMessage":"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.","messagePattern":"Cannot implicitly apply the \"latest\" tag because previously published version (.+?) is higher than the new version (.+?)\\. You must specify a tag using --tag\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/publish.js","lineNumber":180,"sourceCode":"      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) {\n      if (this.isStage) {\n        // Stage intentionally bypasses otplease — 2FA is deferred to approve/reject\n        const res = await libpub(manifest, tarballData, {\n          ...opts,","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/publish.js#L162-L198","documentation":"Thrown by `npm publish` when the new version is lower than or equal to the highest version already published (`semver.gte(highestVersion, manifest.version)`), the `tag` config is at its default (`latest`), and `--force` is not set. npm will not silently demote `latest` to an older release.","triggerScenarios":"Publishing a version where `highestVersion` from the registry `>=` `manifest.version`, while `isDefaultTag` is true (no `--tag`, no `publishConfig.tag`), without `--force`.","commonSituations":"Publishing a patch to an old release line (e.g. `1.2.x`) after `2.0.0` is already `latest`; downgrading; republishing after a hotfix branch merge into a lower minor.","solutions":["Pass an explicit `--tag` (e.g. `--tag legacy` or `--tag lts`) so the older version gets its own dist-tag instead of `latest`.","Set `\"publishConfig\": { \"tag\": \"...\" }` in package.json.","Publish a version strictly greater than the current highest version.","Use `--force` only if you knowingly want to move `latest` to an older version."],"exampleFix":"// before\nnpm publish   // publishing 1.5.1 when 2.0.0 is latest\n// after\nnpm publish --tag backport","handlingStrategy":"validation","validationCode":"const semver = require('semver')\nfunction chooseTag(newVersion, highestPublished, cliTag, publishConfigTag) {\n  const tag = cliTag || publishConfigTag || 'latest'\n  if (highestPublished && semver.gte(highestPublished, newVersion) && tag === 'latest') {\n    return 'backport' // or 'legacy', 'lts' — anything non-latest\n  }\n  return tag\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain a documented dist-tag per release line (e.g. backport, lts).","When publishing from a maintenance branch, default to a non-latest tag.","Check `npm view <pkg> dist-tags` before publishing older versions."],"tags":["publish","semver","dist-tag","downgrade","npm-cli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}