fnm
fnm copied to clipboard
how to have sudo ?
sudo: npm: command not found
this is a permissions thing. I don't assume anything about your setup but I guess the following should work:
sudo "$(which fnm)" exec --using="$(fnm current)" npm --version
let's break it down:
-
sudocalling sudo 👉😎👉 -
"$(which fnm)"expands into"/Users/schniz/Code/fnm/target/debug/fnm"on my machine, but I guess that on your machine it will expand to the location of the fnm binary -
exec- runfnmand add the PATH information needed to the next command (seefnm exec --help) -
--using="$(fnm current)"will expand into your current version of Node.js:--using="16.0.0"if you're using Node.js v16.0.0 -
npm --versionwill be the command to run
Since this obnoxiously explicit command is working, it seems like it isn't an fnm question but more of a specific shell configuration issue so I'm closing it.
If you have any suggestion on how to make it easier I'm all ears :pray: thank you for your contribution :pray: