Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm doesn't work with sudo #44

Open
skarmoutsosv opened this issue Oct 7, 2022 · 3 comments
Open

npm doesn't work with sudo #44

skarmoutsosv opened this issue Oct 7, 2022 · 3 comments

Comments

@skarmoutsosv
Copy link

$ npm -v
8.19.2

$ node -v
v18.10.0

$ which npm
/snap/bin/npm

$ which node
/snap/bin/node

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin

$ npm install nodemon
up to date, audited 33 packages in 762ms
3 packages are looking for funding
run npm fund for details
found 0 vulnerabilities

$ sudo npm install -g nodemon
sudo: npm: command not found

@jpayne
Copy link

jpayne commented Jun 16, 2023

I’m having the same issue. Did you ever figure this out?

@skarmoutsosv
Copy link
Author

Unfortunately no.
I had to use sources other than snap to make it work.

@simondeziel
Copy link
Contributor

simondeziel commented Feb 3, 2025

$ sudo npm install -g nodemon
sudo: npm: command not found

Could you try and see if /snap/bin is in the PATH sudo uses? sudo env | grep ^PATH | grep :/snap/bin should give you one line, like that:

$ sudo env | grep ^PATH | grep :/snap/bin
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

On Ubuntu at least, the default /etc/sudoers file contains this:

Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants