Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

I'm getting this "TypeError: mergeOptions__default.default.bind is not a function" #3838

Closed
@matheusAMDS

Description

@matheusAMDS
  • Version: 0.58.2
  • Platform: Windows 10 64-bit; Brave v1.28.106
  • Subsystem:

Severity: High

Description:

I'm using Next.js. I've created a IPFS provider and used it in my _app.tsx. This is the provider:

import IPFS, { IPFS as IPFSType } from "ipfs"
import { createContext, useContext, useEffect, useState } from "react"

interface IPFSContextInterface {
  ipfs: IPFSType
}

export const IPFSContext = createContext<IPFSContextInterface>(
  {} as IPFSContextInterface
)

export const useIPFS = () => useContext(IPFSContext)

export const IPFSProvider: React.FC = ({ children }) => {
  const [ ipfs, setIPFS ] = useState<IPFSType>({} as IPFSType)

  useEffect(() => {
    async function loadIPFS() {
      const ipfs = await IPFS.create({ repo: "./ipfs" })

      setIPFS(ipfs)
    }

    loadIPFS()
  }, [])

  return (
    <IPFSContext.Provider value={{ ipfs }}>
      {children}
    </IPFSContext.Provider>
  )
}

and this is my _app.tsx

import { AppProps } from "next/app"
import { IPFSProvider } from "../containers/ipfs"

const App: React.FC<AppProps> = ({ Component, pageProps }) => {
  return (
    <IPFSProvider>
      <Component {...pageProps} />
    </IPFSProvider>
  )
}

export default App

When initializing the app i get the error:

Uncaught TypeError: mergeOptions__default.default.bind is not a function
    at Object../node_modules/ipfs-unixfs-importer/cjs/src/options.js (options.js:11)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Object../node_modules/ipfs-unixfs-importer/cjs/src/index.js (index.js:6)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Module../node_modules/ipfs-unixfs-importer/esm/src/index.js (validate-offset-and-length.js:26)
    at Module.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Object../node_modules/ipfs-core/src/components/add-all/index.js (index.js:3)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Object../node_modules/ipfs-core/src/components/root.js (root.js:4)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Object../node_modules/ipfs-core/src/components/index.js (index.js:30)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Object../node_modules/ipfs-core/src/index.js (index.js:10)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Object../node_modules/ipfs/src/index.js (index.js:7)
    at Object.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Module../src/containers/ipfs.tsx (index.js:389)
    at Module.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at Module../src/pages/_app.tsx (web3.tsx:20)
    at Module.options.factory (react refresh:8)
    at __webpack_require__ (bootstrap:25)
    at fn (hot module replacement:61)
    at (index):5
    at route-loader.js:207

It should just work normally

Steps to reproduce the error:

You can reproduce it by creating a new next app with typescript using npx create-next-app. Then adding the previous code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/author-inputNeeds input from the original author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions