nvm icon indicating copy to clipboard operation
nvm copied to clipboard

`nvm use` does not fully respect `--silent`

Open davidosomething opened this issue 9 years ago • 8 comments
trafficstars

It runs nvm_rc_version, which echos "Found ..." and "Now using..." All output should be silenced (or introduce --silence-all or nvm --quiet use or something)

davidosomething avatar Jul 22 '16 05:07 davidosomething

That's a good point. I'm concerned, however, that using the .nvmrc file is so implicit that that output would have real value.

However, I suppose then "not using --silent" would be the recommendation?

ljharb avatar Jul 22 '16 05:07 ljharb

fwiw, you can also do nvm use >/dev/null if you don't want any output.

ljharb avatar Jul 22 '16 08:07 ljharb

I have no problem(the output) when I'm using nvm use 6 --silent, nvm use 4 --silent, is this still a problem here?

PeterDaveHello avatar Aug 05 '16 10:08 PeterDaveHello

@peterdavehello it is only when using a .nvmrc file, not when manually setting the version

davidosomething avatar Aug 05 '16 13:08 davidosomething

I think the semantics of --silent are not necessarily "do not output anything" - since you can use >/dev/null to actually suppress all output.

ljharb avatar Aug 05 '16 20:08 ljharb

for me, I would expect the --silent flag to suppress all console output, which it still doesn't do if you're using nvm use in a directory with an .nvmrc.

I work on a project with lots of different sub modules using different versions of node, so I would like to just alias my cd command to cd $1 && nvm use --silent. That way I don't have to think about switching every time I move to a new dir.

nvm use >/dev/null produces the same console output for me. So that doesn't seem to circumvent the issue.

zipzapp avatar Jun 28 '17 16:06 zipzapp

> /dev/null 2>&1 is how you suppress all console output in all unix commands; it wouldn't really make sense nor be part of the unix philosophy to expect that functionality to be duplicated in-project.

In other words, nvm use >/dev/null 2>&1 will suppress all output.

ljharb avatar Jun 28 '17 18:06 ljharb

> /dev/null 2>&1 is how you suppress all console output in all unix commands; it wouldn't really make sense nor be part of the unix philosophy to expect that functionality to be duplicated in-project.

In other words, nvm use >/dev/null 2>&1 will suppress all output.

--silent/--quiet flags are still useful when you want errors to show, but otherwise suppress any other output. That's what I would expect here.

FYI for anyone coming up on this like I did, I ended up using this as a one-liner to get the node path in a given directory that uses an nvmrc:

ACTUAL_NODE_PATH=$(cd "$TARGET" > /dev/null; nvm which --silent)

tdtm avatar Aug 05 '24 12:08 tdtm