Skip to content
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

Hey Some one please help :- browserify error with webtorrent #2067

Open
adarshchri opened this issue Jul 17, 2023 · 3 comments
Open

Hey Some one please help :- browserify error with webtorrent #2067

adarshchri opened this issue Jul 17, 2023 · 3 comments

Comments

@adarshchri
Copy link

adarshchri commented Jul 17, 2023

browserify index.js -o bundle.js

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (2:0) while parsing C:\Users\chaud\Desktop\webtor\node_modules\webtorrent\index.js while parsing file: C:\Users\chaud\Desktop\webtor\node_modules\webtorrent\index.js
    at DestroyableTransform.end [as _flush] (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\insert-module-globals\index.js:114:21)
    at DestroyableTransform.prefinish (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_transform.js:138:10)
    at DestroyableTransform.emit (node:events:513:28)
    at prefinish (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:619:14)
    at finishMaybe (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:627:5)
    at endWritable (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:638:3)
    at Writable.end (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:594:22)
    at DestroyableTransform.onend (C:\Users\chaud\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:627:28)
    at DestroyableTransform.emit (node:events:525:35)
@adarshchri
Copy link
Author

adarshchri commented Jul 17, 2023

package.json

{
  "name": "webtor",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "browserify": "^17.0.0",
    "webtorrent": "^2.1.12"
  }
}

@adarshchri
Copy link
Author

adarshchri commented Jul 17, 2023

index.js

// Including modules
const WebTorrent = require("webtorrent");
// Initializing WebTorrent
const client = new WebTorrent();

// Using a magnet link
let NewMagnetTorrentId =
  "magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.fastcast.nz&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F";
// Starts downloading a new torrent file
client.add(NewMagnetTorrentId, function (torrent) {
  // Using the .mp4 file
  const file = torrent.files.find(function (Newfile) {
    // Returning filename ending with .mp4
    return Newfile.name.endsWith(".mp4");
  });

  // Display the file by adding it to the DOM.
  file.appendTo("body");
});

@adarshchri
Copy link
Author

index.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<!-- title of the page -->
	<title>WebTorrent video player</title>
</head>

<body>
	<!-- Including script -->
	<script src="./bundle.js"></script>
</body>
</html>

@adarshchri adarshchri changed the title browserify error with webtorrent Hey Some one please help :- browserify error with webtorrent Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant