Error: "Cannot find module './fetch.node'" when using ipfs with Next.js 14 on Vercel

88 views Asked by At

I'm facing an issue with my Next.js project when deploying to Vercel. The error message I'm receiving is:

Error: Cannot find module './fetch.node' This error seems to be associated with the usage of the ipfs module in my project. The error stack trace points to lines in various files, including NFTContext.tsx, ButtonGroup.tsx, Navbar.tsx, index.ts, and page.tsx. The error is triggered when I try to import ipfs using the following code:

import { create as ipfsHttpClient } from "ipfs-http-client";
const client = ipfsHttpClient({url: https://ipfs.infura.io:5001/api/v0,headers: {authorization: auth,},});

Strangely, commenting out this section resolves the error, but it's a critical part of my project, and I need to use ipfs for fetching data and upload image to ipfs

The issue occurs specifically during deployment to Vercel. The error suggests a problem with the fetch.node module. The ipfs module is used with ipfs-http-client. Vercel deployment fails due to this error. What I've Tried:

Commenting out the ipfs related code eliminates the error. Reviewing dependencies and ensuring they are correctly installed.

Has anyone encountered a similar issue when using ipfs with Next.js on Vercel? Are there known compatibility issues between ipfs-http-client and certain environments like Vercel?Are there specific configurations or steps that need to be taken to use ipfs with Next.js on Vercel? Any guidance or insights into resolving this issue would be greatly appreciated. Thank you!

My version of ipfs-http-client is "^60.0.1"

0

There are 0 answers