Couchbase client not seem to work in next JS

I’m trying to connect to our couchase server (we have a private cluster) using nextjs and always ends with this error:

Error: Could not find native build for platform=darwin, arch=arm64, runtime=node, nodeVersion=20.3.1, sslType=openssl3, webpack=true loaded from /Users/maxidr/Projects/mxhero/insight/.next/server.

Here the list of dependencies:

"@types/node": "20.4.1",
    "@types/react": "18.2.14",
    "@types/react-dom": "18.2.6",
    "autoprefixer": "10.4.14",
    "couchbase": "^4.2.5",
    "eslint": "8.44.0",
    "eslint-config-next": "13.4.9",
    "next": "13.4.9",
    "node-gyp": "^9.4.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "tailwindcss": "3.3.2",
    "typescript": "5.1.6"

And here the code:

The complete error:

Thanks for your question @maxidr . Just to confirm, have you followed the instructions here: https://developer.couchbase.com/tutorial-quickstart-nextjs and used the code here: GitHub - couchbase-examples/nextjs-quickstart: The completed code from a tutorial demonstrating how to build a basic front-end and backend CRUD app with Next.js and Couchbase

FYI @ejscribner @ldoguin

Hi @perry ! Yes, I saw your example and it works great. But my problem seems to be when trying to use the bucket in a server-side component (src/app folder)

HI @maxidr, my guess is we don’t currently have a native build for node 20.3.1. Any chance you could downgrade your node version to use node 18 ?

Hi @maxidr – Are you running w/in a container or moving anything around after you have installed the project dependencies? The error you are seeing indicates that for the specified target (Node.js v20, MacOS, ARM arch, etc.) we cannot find the matching binary. What do you see when you run npm list --depth 1? I would expect a block like below to be seen.

├─┬ couchbase@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-darwin-arm64-openssl1@4.2.5
│ ├── @couchbase/couchbase-darwin-arm64-openssl3@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-darwin-x64-openssl1@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-darwin-x64-openssl3@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-linux-arm64-openssl1@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-linux-arm64-openssl3@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-linux-x64-openssl1@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-linux-x64-openssl3@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-linuxmusl-x64-openssl1@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-linuxmusl-x64-openssl3@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-win32-x64-openssl1@4.2.5
│ ├── UNMET OPTIONAL DEPENDENCY @couchbase/couchbase-win32-x64-openssl3@4.2.5

Actually, after looking into things a bit more I am thinking this is related to webpack (error indicates webpack=true). Unfortunately, I am not too familiar w/ front-end applications. Would you be able to provide a minimal example that reproduces the issue? I briefly tried the Couchbase Next.js tutorial and was unable to reproduce the issue (seems to be what you have confirmed as well).

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