Next.js Discord

Discord Forum

codemod unable to apply "latest" on NextJS 16.2.0 -> 16.3.3

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
Pretty self explanatory, honestly. I have a NextJS 16.2.0 project using Bun that cannot seem to execute codemods due to an invalid version matching?

npx @next/codemod@latest upgrade latest
npm notice run private-project@0.1.0 npx
npm notice run codemod upgrade latest
Invalid revision provided: "latest" (resolved to "latest"). Please provide a valid Next.js version, dist-tag (e.g. "latest", "canary", "rc"), or upgrade type ("patch", "minor", "major").
Check available versions at https://www.npmjs.com/package/next?activeTab=versions.

5 Replies

GharialOP
I am not sure what is causing this as it is a valid version.
@Gharial I am not sure what is causing this as it is a valid version.
Himalayan
Hey, have you tried using the built-in upgrade command with Bun?
@Himalayan Hey, have you tried using the built-in upgrade command with Bun?
GharialOP
bun upgrade is a self-updater for Bun itself. bun update checks and updates relevant packages, but it's not a version bump.
@Gharial `bun upgrade` is a self-updater for Bun itself. `bun update` checks and updates relevant packages, but it's not a version bump.
Himalayan
bunx next upgrade or bunx @next/codemod@canary upgrade latest
Tomistoma
"latest" is a valid tag, as the CLI claims otherwise; it's because its version lookup has failed. "@next/codemod upgrade" executes "npm view next@latest" (most likely "--silent"), and if it returns nothing, it outputs "Invalid revision: latest". In a Bun project, that will normally mean that package.json declares "packageManager": "bun@…", and devEngines.packageManager equals "bun"; npm 10.9+ and 11 won't allow even a readonly view there ("EBADDEVENGINES"), and the lookup will fail. The same applies if you call it with npx/npm from a Bun workspace (your npm notice run private-project@0.1.0 npx command line is the case of the mismatch). A temporary problem with the registry and/or network may lead to the same output, but Bun + npm is normally the issue.

Workaround: temporarily remove packageManager/devEngines.packageManager, execute the command, restore it back. You could also enforce npm: $env:npm_config_force="true"; npx @next/codemod@latest upgrade latest. Alternatively, you can skip the tag and provide an exact version: "upgrade 16.2.0". If you only need to apply some transforms without upgrading, you may use a particular codemod, not upgrade latest.