make sure you wrote environment variable in the right place
$ cd $HOME
$ nano .bash_profile
do not wrote if u are in root access like this
# cd $HOME
# nano .bash_profile
just make sure after u are in the right place type this
$ pwd
it should print /Users/your_user
if you are in root access it will print /var/root
I hope it help you
Thank you