On Arch (and likely other linux distributions), installing the hook with:
npm install --global webtorrent-mpv-hook
fails due to insufficient permissions, because npm attempts to write to system directories that require root access. This leads users to run npm with sudo, which is generally discouraged.
Solution
This can be avoided by configuring npm to allow user-wide global installations:
tl;dr add the following to ur shell .profile:
export PATH="$HOME/.local/bin:$PATH"
export npm_config_prefix="$HOME/.local"
For fish users, i've done this by executing fish_add_path ~/.local/bin in the terminal, and then added set -gx npm_config_prefix $HOME/.local to fish's config file.
I'm very new to fish, this can definitely be done better by only using fish's config instead of executing the first command in the terminal. would love to know how.
After configuring a user-level npm prefix, the installation instructions can be followed as-is, without requiring sudo
I believe adding a note like this to the README could help prevent confusion and save time for other users.
do note tho that this may not be needed for every linux system. it probably depends on how node.js was installed, which i imagine varies between distributions.
On Arch (and likely other linux distributions), installing the hook with:
fails due to insufficient permissions, because npm attempts to write to system directories that require root access. This leads users to run npm with
sudo, which is generally discouraged.Solution
This can be avoided by configuring npm to allow user-wide global installations:
$HOME/.local/binto $PATH$HOME/.local)for bash/zsh users, an easy explanation is available in the arch wiki:
https://wiki.archlinux.org/title/Node.js#Allow_user-wide_installations
tl;dr add the following to ur shell .profile:
For
fishusers, i've done this by executingfish_add_path ~/.local/binin the terminal, and then addedset -gx npm_config_prefix $HOME/.localto fish's config file.I'm very new to fish, this can definitely be done better by only using fish's config instead of executing the first command in the terminal. would love to know how.
After configuring a user-level npm prefix, the installation instructions can be followed as-is, without requiring
sudoI believe adding a note like this to the README could help prevent confusion and save time for other users.
do note tho that this may not be needed for every linux system. it probably depends on how node.js was installed, which i imagine varies between distributions.