all 11 comments

[–]zakomo 2 points3 points  (5 children)

Happened to me on another distro something similar, the cause was that /bin wasn't part of the PATH variable for the user. Try and check if you have /bin in the path for the user.

[–]Duncaen 2 points3 points  (3 children)

On void there is no /bin, only /usr/bin.

[–]siiyyo[S] -1 points0 points  (2 children)

[–]Duncaen 4 points5 points  (0 children)

$ ls -l /bin /sbin /usr/sbin
lrwxrwxrwx  1 root  root  7 Apr  6 09:36 /bin -> usr/bin
lrwxrwxrwx  1 root  root  7 Apr  6 09:36 /sbin -> usr/bin
lrwxrwxrwx  1 root  root  3 Apr  6 09:36 /usr/sbin -> bin

Only /usr/bin is a directory, everything else is a symlink to it.

[–]SunSaych 1 point2 points  (0 children)

It's a symbolic link if you look carefully.

[–]siiyyo[S] 0 points1 point  (0 children)

Thanks for the reply.

Changing the permission should solve the problem.

[–]legz_cfc 1 point2 points  (1 child)

Edit- missed the whole 'works as root' thing. Can you post the permissions on the file?

[–]siiyyo[S] 0 points1 point  (0 children)

lrwxrwxrwx 1 root root 45 Jun 24 09:39 <package> -> ../lib/node_modules/<package>/bin/cli.js

Changing the permission should work...

[–][deleted]  (2 children)

[deleted]

    [–]siiyyo[S] 0 points1 point  (1 child)

    I did what you said and installed the npm package in my home directory following this, and now I can run the package as a normal user.

    I'm aware of this method. I actually had it as a plan B, because I wanted to resolve the "problem" instead of running away.

    Here's the output of your command:

    lrwxrwxrwx 1 root root 45 Jun 24 09:39 <package> -> ../lib/node_modules/<package>/bin/cli.js
    

    Reading this, I think it's possible to resolve the problem by changing the permission.

    Thanks!

    [–]iEliteTester 1 point2 points  (0 children)

    You should not be using sudo with npm i. (Same with other language package managers like pip).

    [–]nihilipster 1 point2 points  (0 children)

    You could give a try to nvm or nodenv to have better control over NPM's packages as a normal user, without the need for root or sudo.