These are chat archives for creationix/nvm

15th
Jun 2017
glock18
@glock18
Jun 15 2017 11:56

Hey guys! I hope to find some help here even though this room didn't seem to have much life in last 5 months or so :) I'm trying to run a node script on a service startup (Ubuntu 12.04): it's been running alright this way before I started using nvm:

exec sudo -u strider <script>

Unfortunately, it seems that $PATH is the one of a root user when the command is run like this meaning that bash sees neither the script nor the node executable.

I feel so stupid right now, as it seems like an issue that must've already been solved so many times, but I still can't get it working as well finding anything helpful on the matter. Maybe someone can point me at how it can be done?

Jordan Harband
@ljharb
Jun 15 2017 15:08
@glock18 yes, nvm is per-user, so it's not compatible with sudo
so if you want root to have nvm, it needs its own installation of nvm, and your script probably will need to source nvm.sh
glock18
@glock18
Jun 15 2017 15:14
@ljharb thank you for response. No, of course I don't want to run any of this as a root user. For now I'm gonna be passing right PATH to the command, which might be not-to-good of a solution, but at least it doesn't require shenanigans with multiple installations of nvm, node or whatnot.
Jordan Harband
@ljharb
Jun 15 2017 23:21
@glock18 makes sense. ideally the script wouldn't need sudo at all tho :-)