Task
I want to use the path returned by npm bin -g
in a script.
Problem
npm bin -g
returns the path then also prints to a new line that it isn't part of PATH env variable:
/home/username/.npm-global/bin
(not in PATH env variable)
To make it even more random, sometimes it prints this upgrade notice too:
╭─────────────────────────────────────╮
│ │
│ Update available 5.3.0 → 5.6.0 │
│ Run npm i -g npm to update │
│ │
╰─────────────────────────────────────╯
These cause an error message in my script and halts its execution.
What have I tried
I tried to process only the first line of the output with npm bin -g | head -n 1
but the second line still persists. I even tried npm bin -g > /dev/null
but that made only the path go away, I still have the notice. What is going on?