NextJS: Can't resolve 'magic-sdk' and '@walletconnect/web3-provider'
See original GitHub issueNew 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
- I am not disclosing a vulnerability.
- I have searched through existing issues and the Moralis Forum.
- I can reproduce the issue with the latest react-moralis release, latest SDK release, and my server is updated to the latest version.
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:
- Created 2 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello,
I also have this issue, but I’m not using NextJS, only classic React.
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: