nvm: Cannot call `nvm exec` in bash script with `set -e`
If I call nvm exec node foobar.js
in a bash script with set -e
everything exits early, this is not great for being able to use nvm in an automated build for example . . .
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 22 (11 by maintainers)
It appears
nvm install <version>
fails whenset -e
is used also. Here’s an example script I’m using:The offending non-zero returning function is
nvm_version_greater
, called fromnvm_version_path
. Should I open a new ticket for this?@kncs thanks - i was able to find the line causing the error. Definitely every file ever should have a trailing newline, but, I’ll figure out a way to make this not break.
I don’t know if it could help someone but I just solve a similar problem using set -e and nvm into a bash script. The problem was a missing line break into the .nvmrc file.
How to reproduce it :
Remove line break into the .nvmrc
Launch script and observe.
@joscha when the version is omitted and no
.nvmrc
is present, it does fail (and should) - is that the situation for you?