New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Issue with Next.js: Can't resolve 'dgram' #2771
Comments
Hi @oviirup, Getting this error typically means that whatever bundler you are using isn't respecting the browser overrides used to build the browser version of WebTorrent, which seems to be a known issue with next.js. I would recommend using the pre-built browser version from |
@SilentBot1 thanks for the solution. I kept the 'use client';
import React from 'react';
import WebTorrent from '@/lib/webtorrent';
export default function HomePage() {
const client = React.useRef();
React.useEffect(() => {
// ignore in server and run only in client
if (typeof window === 'undefined') return;
client.current ??= new WebTorrent(); //! ERROR
}, []);
return <main>This is main page</main>;
} In the development server it gives this error
Though the torrent file is loaded successfully, but this error breaks the build process. |
I am trying to create a project with
Next.js
andwebtorrent
, but I am getting an error message that says:I tried several combinations for managers and node versions, still there was error. I also tried it in
vite
project (different error). I tried installing the packagedgram
which is deprecated, but the result is the same.Reproduction process
initiate a next project with all the default values...
Go the the index page:
app/page.js
, clear out the contents and paste in the following code.Package details
webtorrent: v2.2.1
next: v14.1
react: v18.2
System details
Windows 11,
node v18, v20, v21
pnpm v18.15.5
yarn v1.22.22
The text was updated successfully, but these errors were encountered: