Snap of npm always selected before local package

I’m developing apps using npm. The node snap, which I’m using, already provides also npm and yarn.

Unfortunately using npm though the snap creates a number of issues, most of which got fixed by setting npm’s default dir to my home folder (Option 2).

However, the snapped npm still takes precedence over the locally installed one.

$ ~/.npm-global/bin/npm --version
7.7.5
$ echo $PATH
/home/fabio/gems/bin:/home/fabio/.pyenv/plugins/pyenv-virtualenv/shims:/home/fabio/.pyenv/shims:/home/fabio/.pyenv/bin:/home/fabio/.yarn/bin:~/.npm-global/bin:/home/fabio/.cargo/bin:/home/fabio/.local/bin:/home/fabio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$ which npm
/snap/bin/npm

I would like ~/.npm-global/bin/npm to be my default npm but I’m not sure how to make this happen :confused:

Have you tried preparing the desired location to $PATH? Setting this in your shell profile PATH=$HOME/.npm-global/bin:$PATH should be enough.

Yes, if you check my (admittedly long) $PATH, I have ~/.npm-global/bin way before /snap/bin.

May it be that ~ is not getting expanded?

Indeed that was the issue, my bad :sweat_smile: Thanks a lot :blush: