posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

Posthog Nuxt sourcemaps failed to process

Open frasza opened this issue 1 month ago • 2 comments

Bug description

I have followed the instructions to integrated @posthog/nuxt module to generate sourcemaps and track the errors, but whenever I try to run npm run generate (I am running SPA mode) I get errors in my console.

Error: spawnSync C:\Users\zanfr\Development\Projects\x\web\node_modules\@posthog\cli\node_modules\.bin_real\posthog-cli.exe ENOENT
    at Object.spawnSync (node:internal/child_process:1120:20)
    at spawnSync (node:child_process:902:24)
    at C:\Users\zanfr\Development\Projects\x\web\node_modules\@posthog\cli\binary-install.js:197:24
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawnSync C:\\Users\\zanfr\\Development\\Projects\\x\\web\\node_modules\\@posthog\\cli\\node_modules\\.bin_real\\posthog-cli.exe',
  path: 'C:\\Users\\zanfr\\Development\\Projects\\x\\web\\node_modules\\@posthog\\cli\\node_modules\\.bin_real\\posthog-cli.exe',   
  spawnargs: [
    'sourcemap',
    'inject',
    '--ignore',
    '**/node_modules/**',
    '--directory',
    '.output\\public'
  ]
}
Failed to process public sourcemaps: Error: Command failed with code 1
    at ChildProcess.<anonymous> (file:///C:/Users/zanfr/Development/Projects/x/web/node_modules/@posthog/core/dist/process/spawn-local.mjs:13:25)
    at ChildProcess.emit (node:events:519:28)
    at cp.emit (C:\Users\zanfr\Development\Projects\x\web\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5)
    at Process.callbackTrampoline (node:internal/async_hooks:130:17)
✔ You can preview this build using npx serve .output/public                                                          nitro 13:02:52
Error: spawnSync C:\Users\zanfr\Development\Projects\x\web\node_modules\@posthog\cli\node_modules\.bin_real\posthog-cli.exe ENOENT
    at Object.spawnSync (node:internal/child_process:1120:20)
    at spawnSync (node:child_process:902:24)
    at C:\Users\zanfr\Development\Projects\x\web\node_modules\@posthog\cli\binary-install.js:197:24
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawnSync C:\\Users\\zanfr\\Development\\Projects\\x\\web\\node_modules\\@posthog\\cli\\node_modules\\.bin_real\\posthog-cli.exe',
  path: 'C:\\Users\\zanfr\\Development\\Projects\\x\\web\\node_modules\\@posthog\\cli\\node_modules\\.bin_real\\posthog-cli.exe',   
  spawnargs: [
    'sourcemap',
    'inject',
    '--ignore',
    '**/node_modules/**',
    '--directory',
    '.output\\server'
  ]
}

 ERROR  Failed to process server sourcemaps: Command failed with code 1                                                     13:02:53  

    at ChildProcess.<anonymous> (/C:/Users/zanfr/Development/Projects/x/web/node_modules/@posthog/core/dist/process/spawn-local.mjs:13:25)
    at ChildProcess.emit (node:events:519:28)
    at cp.emit (node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5)
    at Process.callbackTrampoline (node:internal/async_hooks:130:17)

How to reproduce

  1. npm install @posthog/nuxt on my existing Nuxt project
  2. Added @posthog/nuxt as a module to nuxt.config.ts
  3. Configurated config related to official docs and steps

Related sub-libraries

  • [ ] All of them
  • [ ] posthog-js (web)
  • [ ] posthog-js-lite (web lite)
  • [ ] posthog-node
  • [ ] posthog-react-native
  • [ ] @posthog/react
  • [ ] @posthog/ai
  • [ ] @posthog/nextjs-config
  • [x] @posthog/nuxt

Additional context

Node v24

Thank you for your bug report – we love squashing them!

frasza avatar Nov 09 '25 12:11 frasza

@PostHog/team-error-tracking

marandaneto avatar Nov 17 '25 08:11 marandaneto

What Nuxt module is doing under the hood is calling our posthog-cli.

You are getting ENOENT error which indicates that the file does not exist or can't be accessed.

Could you verify whether you are able to run this file manually?

Try running this in your terminal

C:\Users\zanfr\Development\Projects\x\web\node_modules\@posthog\cli\node_modules\.bin_real\posthog-cli.exe

ablaszkiewicz avatar Nov 17 '25 08:11 ablaszkiewicz