Skip to content

Suggestion: Document user-level npm global installs for Linux (avoid sudo) #44

@DeXfiR

Description

@DeXfiR

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions