create .bash_profile file
cd ~
touch .bash_profile
open the file you just created
open .bash_profile
paste the following code inside the file
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
run the source command after saving
source .bash_profile
then enter the command
nvm --version
Then the version number of nvm will appear.
Nvm of official github readme.md can't solve the problem of command not found.
To install nvm, i am use the install script cURL.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
My macbook pro 2019 was bought yesterday.
According to my method, the problem that command not found, on my MacBook Pro is solved.
The solution is reproduced from https://github.com/SunXinFei/sunxinfei.github.io/issues/6#issue-306510213
I鈥檓 not really sure what you鈥檙e saying here.
On a new Mac, you definitely may have to create bash_profile before running the install script - as documented in the readme.
@ljharb
I followed the instructions in the readme file.
Maybe the readme file is correct but Maybe I misunderstood the contents of the readme file.
The code in the readme file is
NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
I wrote this code into the .bash_profile file, run the source .bash_profile command, and run the 'nvm --version' command, prompting 'comman not found'.
According to the method of issue #2060, after running nvm --version will display the version number of nvm normally.
Maybe I misunderstood the contents of the readme file.If this issues is bothering you, I apologize to you, I am very sorry.
My native language is not English. Maybe the language barrier has caused some resistance to my correct understanding of the contents of the readme file.I will work harder to learn English in the future.
If this is a useless issues, please turn it off and I don't want it to affect other developers.
Thank you!
I'm specifically referring to the https://github.com/nvm-sh/nvm#install--update-script section, under the third "note":
On OS X, if you get nvm: command not found after running the install script, one of the following might be the reason:
- your system may not have a
.bash_profile filewhere the command is set up. Simply create one withtouch ~/.bash_profileand run the install script again- you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
@ljharb
you are right.
My computer does not have a .bash_profile file before running the install script.
I created the .bash_profile file after running the install script.
So the code is different from yours,
Your code is
NVM_DIR = "${XDG_CONFIG_HOME / - .$HOME /} NVM"
[-s"$NVM_DIR / nvm.sh"] && \. "$NVM_DIR / nvm.sh"#This will load nvm
After running the installation script, I created the .bash_profile file and entered the code different from your code into the ".bash_profile" file.
This is my problem, I will close this issue after 10 minutes to avoid the position of this issues ahead of other issues.
I apologize to you.
No problem at all, glad we cleared it up :-)
@ljharb
nice!
btw it has a typo, you need to change source bash-profile to source bash_profile
Thanks, fixed.