Nvm: Everytime I get .nvm/nvm.sh: line 62: syntax error near unexpected token `}'

Created on 3 May 2018  路  9Comments  路  Source: nvm-sh/nvm

On mac os x, in .bash_profile, everytime I get .nvm/nvm.sh: line 62: syntax error near unexpected token `}'

non-issue / invalid shell alias clobbering

Most helpful comment

After removing bash_profile and other config files and RESTARTing iTerm, everything worked ! Well done, I am an happy user of nvm now

All 9 comments

What did it end up being?

After removing bash_profile and other config files and RESTARTing iTerm, everything worked ! Well done, I am an happy user of nvm now

In fact, I found that the issue was because the file .bash_profile where I put
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

... was using UNIX LF. To remove the error, you have to setup Unicode UTF-8 and Windows CRLF.

Would be great to have this working without having to setup bash_profile with these parameters! For the moment, I use UNIX LF in the .bash_profile and Windows CRLF in .bashrc. And it's good. A.

I'm confused; why would bashrc - a linux file - use anything but LF?

Certainly a mix of line endings would break things, glad you figured it out.

I was wrong. In fact, I figured out what causes the issue: in my .bash_profile, there is the alias "alias fi='sudo find . -iname'"
When I remove it, it works!

That definitely would break literally everything, since that's part of POSIX if statement control structures :-)

I don't know much about POSIX, but did you reproduce locally ?

Yes, I definitely reproduced it locally.

Using \fi doesn't fix it, so I'm really not sure how it would be possible to address inside nvm.

Same issue. I believe the reason is because some foreign characters in your .bash_profile file. (Especially, it happens when you copy paste something).

Was this page helpful?
0 / 5 - 0 ratings