question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NextJS: Can't resolve 'magic-sdk' and '@walletconnect/web3-provider'

See original GitHub issue

New Bug Report

WIth a new nextjs project, running yarn dev or npm run dev results in immediate warnings:

warn  - ./node_modules/moralis/lib/browser/Web3Connector/MagicWeb3Connector.js
Module not found: Can't resolve 'magic-sdk' in '/<project-path>/node_modules/moralis/lib/browser/Web3Connector'

Checklist

Issue Description

yarn create next-app
yarn add moralis react-moralis

Then, update your _app.js file to look something like:

import { MoralisProvider } from "react-moralis"

function App({ Component, pageProps }) {
  return (
    <MoralisProvider initializeOnMount={false}>
      <Component {...pageProps} />
    </MoralisProvider>
  )
}

export default App

Then run:

yarn dev

And you’ll see the warnings. If you go ahead and add that package, you then get it complaining about not finding @walletconnect/web3-provider

Actual Outcome

warn  - ./node_modules/moralis/lib/browser/Web3Connector/MagicWeb3Connector.js
Module not found: Can't resolve 'magic-sdk' in '/<project-path>/node_modules/moralis/lib/browser/Web3Connector'

Expected Outcome

No warnings

Environment

    "moralis": "^1.2.3",
    "next": "12.0.9",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-moralis": "^1.2.1"

macos Monterey 12.1 yarn: 1.22.17

Server - N/A

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
Kipitupcommented, Feb 24, 2022

Hello,

I also have this issue, but I’m not using NextJS, only classic React.

2reactions
theitaliandevcommented, Feb 17, 2022

Since these are optional dependencies and these warnings comes from Webpack 5 (in Next.js v. 12 the support for Webpack 4 was removed) I’ve got rid of them by customising webpack config in next.config.js as follow:

module.exports = {
    webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
      config.ignoreWarnings = [
        {
          message: /(magic-sdk|@walletconnect\/web3-provider|@web3auth\/web3auth)/,
        }
        
      ]
      return config
    },
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'magic-sdk'
How do I fix these errors? I am using webpack 5 with react-rewired-app scripts. ... Yes. It just leads to more terminal errors....
Read more >
Issues · MoralisWeb3/react-moralis - GitHub
Next.js TypeError: Right-hand side of 'instanceof' is not callable ... NextJS: Can't resolve 'magic-sdk' and '@walletconnect/web3-provider'.
Read more >
Metamask Authentication with Moralis, Next.js and ... - Ckmobile
To add this package, we can go to the terminal yarn add moralis react-moralis. You may get “Module not found: Can't resolve 'magic-sdk'”...
Read more >
Build error when compiling Next.js app using next-pwa
Mainly extracting pwa config from mixing into rest of the next.js config. ... webpack5: true, webpack: (config) => { config.resolve.fallback ...
Read more >
@walletconnect/web3-provider - npm
Web3 Provider for WalletConnect. Latest version: 1.8.0, last published: 5 months ago. Start using @walletconnect/web3-provider in your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found