Why is my function crashing when trying to require couchbase?

Does anyone know what to do about the error I’ve pasted below? I kind of understand what it’s trying to tell me but I haven’t changed any dependencies as far as I know. I know it’s being triggered by this line in my Netlify function:

const couchbase = require('couchbase')

But up until recently that same code was working fine. And my project is building and deploying without error; I only see the error below when I try to load the function in a browser.

It still works locally with netlify dev; I’m only seeing this error on netlify.app.

Also, I see this same error with a similar function deployed to Vercel. Meanwhile, I am able to require(‘mongodb’) on both platforms without error.

This function has crashed
An unhandled error in the function code triggered the following message:

Error - Could not find native build for platform=linux, arch=x64, runtime=napi, nodeVersion=22.15.1, sslType=openssl3, libc=linux loaded from /var/task/node_modules/couchbase.

Stack trace
Error: Could not find native build for platform=linux, arch=x64, runtime=napi, nodeVersion=22.15.1, sslType=openssl3, libc=linux loaded from /var/task/node_modules/couchbase.
    at resolvePrebuild (/var/task/node_modules/couchbase/scripts/prebuilds.js:501:9)
    at Object.loadPrebuild (/var/task/node_modules/couchbase/scripts/prebuilds.js:362:25)
    at Object.<anonymous> (/var/task/node_modules/couchbase/dist/binding.js:176:41)
    at Module._compile (node:internal/modules/cjs/loader:1730:14)
    at Object..js (node:internal/modules/cjs/loader:1895:10)
    at Module.load (node:internal/modules/cjs/loader:1465:32)
    at Function._load (node:internal/modules/cjs/loader:1282:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1487:12) 

Hi @andrewpfunk
This might be Jira. I’ve pinged this post to our internal channels.

As I was browsing Netlify project settings I noticed a warning under Dependency management saying Node.js 18.x was at end of life. I changed it to the recommended 22.x. I’m not sure if that’s what fixed it but my functions are no longer crashing.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.