oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.44k stars 2.78k forks source link

[bunx] Script not found "codemod@latest" #14596

Open leerob opened 1 month ago

leerob commented 1 month ago

What version of Bun is running?

1.1.30+7996d06b8

What platform is your computer?

Darwin 23.4.0 arm64 arm

What steps can reproduce the bug?

  1. On a Next.js repo, run npx @next/codemod@canary upgrade rc or bunx version
  2. The script fails with the following stack trace:
error: Script not found "codemod@latest"
Error: Command failed: bunx codemod@latest react/19/migration-recipe --no-interactive
    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at runUpgrade (/Users/leerob/.npm/_npx/6a090669e21b4303/node_modules/@next/codemod/bin/upgrade.js:208:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Command.<anonymous> (/Users/leerob/.npm/_npx/6a090669e21b4303/node_modules/@next/codemod/bin/next-codemod.js:51:9) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 23902,
  stdout: null,
  stderr: null
}
  1. Then, I tried to run bunx codemod@latest react/19/migration-recipe --no-interactive directly:
bunx codemod@latest react/19/migration-recipe --no-interactive
error: Script not found "codemod@latest"

Strangely, it works for a coworker who is also on bun 1.1.30 and macOS with Darwin 23.6.0 arm64 arm.

What is the expected behavior?

The codemod runs as expected.

What do you see instead?

No response

Additional information

No response

Jarred-Sumner commented 1 month ago

for some reason, it's not realizing that bunx is not bun

n2k3 commented 4 weeks ago

Running

both give this error on my machine:

node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module '.bin/jscodeshift'
Require stack:
- C:\Users\[redacted]\AppData\Local\Temp\bunx-1560605942-@next\codemod@latest\node_modules\@next\codemod\bin\transform.js
- C:\Users\[redacted]\AppData\Local\Temp\bunx-1560605942-@next\codemod@latest\node_modules\@next\codemod\bin\upgrade.js
- C:\Users\[redacted]\AppData\Local\Temp\bunx-1560605942-@next\codemod@latest\node_modules\@next\codemod\bin\next-codemod.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at Object.<anonymous> (C:\Users\[redacted]\AppData\Local\Temp\bunx-1560605942-@next\codemod@latest\node_modules\@next\codemod\bin\transform.js:21:41)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (C:\Users\[redacted]\AppData\Local\Temp\bunx-1560605942-@next\codemod@latest\node_modules\@next\codemod\bin\upgrade.js:38:21) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\[redacted]\\AppData\\Local\\Temp\\bunx-1560605942-@next\\codemod@latest\\node_modules\\@next\\codemod\\bin\\transform.js',
    'C:\\Users\\[redacted]\\AppData\\Local\\Temp\\bunx-1560605942-@next\\codemod@latest\\node_modules\\@next\\codemod\\bin\\upgrade.js',
    'C:\\Users\\[redacted]\\AppData\\Local\\Temp\\bunx-1560605942-@next\\codemod@latest\\node_modules\\@next\\codemod\\bin\\next-codemod.js'
  ]
}

Node.js v20.11.1

running bunx --bun @next/codemod@canary upgrade latest gives

error: Cannot find module '.bin/jscodeshift' from 'C:\Users\[redacted]\AppData\Local\Temp\bunx-1560605942-@next\codemod@canary\node_modules\@next\codemod\bin\transform.js'

Bun v1.1.33 (Windows x64)

using bun 1.1.33+247456b67, on Microsoft Windows NT 10.0.22631.0 x64 (Windows 11 Pro 23H2)

JohnC0de commented 1 week ago

Hey, I'm also running into issues with @next/codemod on Bun. I'm on Windows 11 Pro and tried both 1.1.35 Canary and 1.1.34 - no luck. Works fine with pnpm and npm though.

I tried pretty much every Bun command I could think of:

But nope, same error every time. Any ideas what I'm doing wrong here? Would love to get this working with Bun.