-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-bash: nvm: command not found #576
Comments
Having However, you do need to Can you check your |
Please reopen if you discover this is actually a problem with |
I had the same issue until I added the following lines to my
|
Hmm, |
I was having the same issue. After installing nvm, I had to exit from bash and re-login to make it work (I read it somewhere earlier). I think we should update the README. Tried on CentOS 7 in VM (dev installation mode, CLI only). |
Hi, I've got the same problem on Mac OS X 10.10 Yosemite. I've installed nvm with the command : This add the following lines in my .bashrc file: And I also add the following line at the bottom of the same file: But it doesn't work. I must execute this last command every time I want use nvm. Any idea ? |
@jeancdc However, unless you run something like |
But still the same problem when I quit the terminal and restart it... I must execute |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm |
@jeancdc does that fix your issue? |
It was already two lines. Maybe I made wrong when I copied-paste this. |
OK, I've done the same thing than @alfredbez and it works: Like he said, I must to add the following lines at the end of the
Maybe the author @creationix should add these instructions in the README.markdown file. Thanks to you ! |
@jeancdc Usually the install script does it for you, so nothing is needed in the readme. what OS are you using? |
I use Mac OS X 10.10.2 Yosemite |
@jeancdc I'm not sure how you installed |
with this command: |
yup, that should do it. On a hunch - do you use any other shells? What does It's possible that it's already in your |
I use the default terminal. This is the result of the command:
|
If you check If so, then it's that the install script's shell detection is a bit wonky. |
Here is what there are in the
Nothing in the |
Gotcha, thanks. Adding |
So, does that mean that the install script of NVM need some fix ? |
Yes, #592 is probably the closest issue to it. |
putting in /etc/profile worked for me |
The solution of @wonderdogone works for me. Before, I tried the solutions suggested by @ljharb in response to @jeancdc. Is possible that the problem is related with the permissions of the .bashrc file? Is the best way to solve this issue, edit the profile file like @wonderdogone comment? Again, that solution works for me too. |
The installation script's primary jobs are:
The second one is extremely difficult and error-prone. If at any time it fails for you, adding those two lines (#576 (comment)) to the appropriate profile file for your shell should solve it. |
I had that issue as well in Yosemite It seems the |
For my case, it was a permissions issue with the license! I needed to download the Developer Command Line tools from Apple (not the whole XCode) – and accept the license – then, with all these solutions, it worked like a charm. Link for Command Line License Download: https://developer.apple.com/download/more/ |
After this close terminal and open it again before banging your head on wall |
nvm automatically put the following lines in .bashrc and I was getting the
I moved these lines to .bash_profile and it started working. |
将~/.bashrc 复制到 ~/.bash_profile 重启终端
成功解决 |
export NVM_DIR=~/.nvm |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This still works. |
I'm not trying to be hostile, this issue has been open for 7 years, I'm honestly supposed that there hasn't been a solution in that time. |
@blazestudios23 no, the issue has been closed for 6 years. This (very long) thread contains a half dozen different problems, all of which are solved if you take the time to read the entire thread. If you're still having a problem, please file a new issue. Commenting on this long and old one isn't going to help get anything solved. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Something to be aware of, which tripped me up for an hour, is that malderete-ltm:~ malderete$ nvm --version
0.38.0
malderete-ltm:~ malderete$ which nvm
malderete-ltm:~ malderete$ which node
malderete-ltm:~ malderete$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v14.17.5...
Downloading https://nodejs.org/dist/v14.17.5/node-v14.17.5-darwin-x64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v14.17.5 (npm v6.14.14)
Creating default alias: default -> lts/* (-> v14.17.5)
malderete-ltm:~ malderete$ nvm use --lts
Now using node v14.17.5 (npm v6.14.14)
malderete-ltm:~ malderete$ which node
/Users/malderete/.nvm/versions/node/v14.17.5/bin/node (As someone who is only semi-command line literate, I lean on the |
@alderete-sfdc |
@ljharb Oh, yes, it's mentioned in a couple places. Quite clearly! I'm just making a quick note for people like me, who know just enough to think they can skip the "easy" parts of the docs. When I finally noticed the difference, the part I'd been skipping, I groaned out loud and metaphorically head-desked. (As a "professional" technical writer, it's especially embarrassing.) Just posting a quick note, in case there are others who might be doing the same thing. (Since, as you pointed out in an relatively recent comment, this issue has been closed for years, and yet people are still somehow having problems. Mine was that I was being an idiot.) I hope it's viewed as constructive, not a complaint—that's certainly my intent! |
If you installed nvm by hombrew, add this to
|
If you installed nvm by homebrew, uninstall it and use a supported installation method. |
This worked fine for me. Thanks a lot! |
I faced the same issue, what worked for me was https://dev.to/duhbhavesh/nvm-command-not-found-1ho The gist of it was to add: export` NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm to nano ~/.zshrc |
can anyone explain how should i approach this |
approach? Just run that command, verbatim |
I faced an issue with populating I install nvm via brew on my Ubuntu 22.04. I have added recommended lines export NVM_DIR="$HOME/.nvm"
[ -s "/home/linuxbrew/.linuxbrew/opt/nvm/libexec/nvm.sh" ] && \. "/home/linuxbrew/.linuxbrew/opt/nvm/libexec/nvm.sh" # This loads nvm
[ -s "/home/linuxbrew/.linuxbrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/home/linuxbrew/.linuxbrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion to my Then I called However, when I either just close terminal or log out/reboot, I don't have I noticed that However, I noticed that
I noticed if I create #!/bin/bash
[ -s "/home/linuxbrew/.linuxbrew/opt/nvm/libexec/nvm.sh" ] && \. "/home/linuxbrew/.linuxbrew/opt/nvm/libexec/nvm.sh" # This loads nvm
[ -s "/home/linuxbrew/.linuxbrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/home/linuxbrew/.linuxbrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion However, if I use Does anybody have any idea why running Versionsnvm: 0.39.3 |
@pahan35 nvm is unsupported via homebrew; can you try installing it with the only proper installation method, the install script in the readme? |
@ljharb I fixed my issue by moving nvm initialization call to my Basically, I appended next lines. if ! hash nvm &>/dev/null; then
# We need to load nvm on each terminal session since it's not populated, if ran from ~/.profile
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "/home/linuxbrew/.linuxbrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/home/linuxbrew/.linuxbrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
fi @ljharb could you please provide any more details on why nvm is unsupported via homebrew? |
@pahan35 because i, the sole maintainer, don't distribute it on homebrew, and as such, it's unsupported. More specifically, there are a number of bugs users experience from the brew install, including that installed nodes are lost when updating nvm. |
@ljharb, I've tried installation from the mentioned in https://github.com/nvm-sh/nvm/blob/master/README.md#install--update-script, and it looks like here is the same issue.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion If the same commands are placed in So, potentially, the issue with installation via homebrew is only in mentioning the wrong place to add init lines. |
I don't think Mac bash sources |
And I also was not completely clear about how everything is processed with those dotfiles before reading this answer https://askubuntu.com/a/1012937/667572, where is an excellent explanation of when and what is loading. TL;DR
So, what I can say is that `~/.profile` is evaluated all the time on the login into **Ubuntu 22.04.1 LTS** with **GNOME 42.5**. I checked it by setting the env variable. So, if I add anything like
```bash
export NVM_DIRR="checkme"
```
to `~/.profile`, I can easily read it with echo in the terminal, opened via GUI.
```bash
$ echo $NVM_DIRR // prints "checkme" (without quotes) on a new line.
```
|
Running terminal in Mac OS X Yosemite.
Followed the installation instructions and restarted terminal:
curl https://raw.githubusercontent.com/creationix/nvm/v0.18.0/install.sh | bash
When using nvm I always get -bash: nvm: command not found
When installing again:
=> nvm is already installed in /Users/Tony/.nvm, trying to update
=> HEAD is now at 5f5eb47... v0.18.0
I do have npm already installed. Does that matter?
The text was updated successfully, but these errors were encountered: