webtorrent / webtorrent-cli

WebTorrent, the streaming torrent client. For the command line.
https://webtorrent.io
MIT License
1.16k stars 133 forks source link

WebTorrent unable to run from npm install, assert error #309

Closed NullCode1337 closed 3 months ago

NullCode1337 commented 3 months ago

What version of this package are you using? Running npm install webtorrent-cli -g from arch terminal

What operating system, Node.js, and npm version? Arch Linux Hyprland, Node.js v22.3.0, npm@10.8.1

What happened? Followed guide to install node, npm, and webtorrent Tried to run webtorrent, error:

nullcode1337@MONARCH ~ [1]> s webtorrent
[sudo] password for nullcode1337:
file:///usr/lib/node_modules/webtorrent-cli/node_modules/webtorrent/index.js:20
import info from './package.json' assert { type: 'json' }
                                  ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:164:18)
    at callTranslator (node:internal/modules/esm/loader:429:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:435:30)

Also happens when not running webtorrent via sudo, npm installation without sudo failed and I needed it for install

What did you expect to happen? WebTorrent help menu to appear

Are you willing to submit a pull request to fix this bug? As long as I'm guided to it

SilentBot1 commented 3 months ago

Hi there,

This is linked with an already registered issue in WebTorrent, which can be found here: https://github.com/webtorrent/webtorrent/issues/2777

Due to this issue, webtorrent (and webtorrent-cli) will not work with NodeJS 22 until this is fixed and you would have to downgrade to NodeJS 21 or wait for a fix.

I'll aim to look at this today, and will try and get a fix pushed out for this.

SilentBot1 commented 3 months ago

Sorry, the above PR actually broke webtorrent-cli in it's entirety... will have to wait for 5.1.2 which will include a fix for this issue and for webtorrent-cli not working. Please keep an eye on https://github.com/webtorrent/webtorrent-cli/pull/311 for the fix.