nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
78.88k stars 7.9k forks source link

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

Open davidosomething opened 8 years ago

davidosomething commented 8 years ago

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)

ljharb commented 8 years ago

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 commented 8 years ago

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

PeterDaveHello commented 8 years ago

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

davidosomething commented 8 years ago

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

ljharb commented 8 years ago

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

zipzapp commented 7 years ago

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.

ljharb commented 7 years ago

> /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.

tdtm commented 1 month ago

FYI for anyone coming up on this like I did, I ended up using this as a one-liner:

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