Brew install nvm. nvm: command not found - homebrew

After installing nvm with brew, and running nvm, it says nvm: command not found
How can I get the command to execute?

There are two steps to installing nvm with brew.
First use brew to install the application:
brew install nvm
Then take a look at the brew info "caveats" section, to see what else you have to do:
brew info nvm
You might see something like (this can change!):
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to ~/.bash_profile or your desired shell
configuration file:
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
If you do not have a ~/.bash_profile file, then you can simply create one.
Make sure to restart your terminal before trying to run the nvm command again.

I followed #user3207874's answer, but it still wasn't working for me. I had to run this command after those steps:
source $(brew --prefix nvm)/nvm.sh

From the docs:
Your system may not have a [.bash_profile file] where the command is
set up. Simply create one with touch ~/.bash_profile and run the
install script again
you might need to restart your terminal instance. Try opening a new
tab/window in your terminal and retry.
Restarting worked for me...Why can't all bugs be so easy?!!

Just adding some explanation for Aaditya's answer to explain why it works. I can't replay because I don't have enough reputation.
Basically there are 2 important steps to follow
Export NVM_DIR location. You need to create this folder if it doesn't exist first.
export NVM_DIR="$HOME/.nvm"
Second you need to source nvm's script. It is usually like this
. "/usr/local/opt/nvm/nvm.sh"
If the path on the second step does work it may be because the path is different in your device. One easy way to find its path is with the command
brew --prefix nvm
The output will be the path for the nvm installation directory in which the nvm.sh file resides. Setting the command inside $() will create a subshell to get that path. We can use it to source the nvm.sh script wherever it is located like this:
. $(brew --prefix nvm)/nvm.sh
Using that command is a replacement for . "/usr/local/opt/nvm/nvm.sh" in your .bash_profile.

please run this command
source ~/.nvm/nvm.sh

I had the same problem after running npm install
The following solution worked for me:
Run brew doctor to find broken symlinks for NPM
Run brew cleanup to clean them up

Just adding some new info.
The docs for nvm have this note:
Homebrew installation is not supported. If you have issues with homebrew-installed nvm, please brew uninstall it, and install it using the instructions below, before filing an issue.
So for anyone coming here, potentially uninstall via brew and install as per recommendation : https://github.com/nvm-sh/nvm

Related

Finding the binary's name after package installation

When I installed 7zip via home brew (Formula sevenzip), i noticed that i cannot run it via sevenzip and even brew info sevenzip did not tell me the name of the binary.
Only after looking in the script file on Github I noticed a command 7zz but there must be an easier way to find out the binaries or commands associated with a homebrew package.
The simplest I know is:
brew ls PACKAGE
and you can normally see it pretty quickly. Personally, I use p7zip as PACKAGE.
Alternatively, as brew --prefix tells you where binaries are installed (via symlinks), you can find the newest installed binary with:
ls -lrt $(brew --prefix)/bin
and it's the last one listed.

How to install Gridsome: zsh: command not found: gridsome

I'm attempting to create a new Gridsome project and continually receive the following message in the terminal:
zsh: command not found: gridsome
Steps I've taken
(https://gridsome.org/docs/)
npm install --global #gridsome/cli
cd testProjects
gridsome create my-gridsome-site
At this point i receive the error and cannot seem to find a way to resolve it.
I solved this by using yarn for installation. So simply run the following commands :
Install yarn. On Mac OS do it using homebrew. brew install yarn.
cd to place where you would like your project to be, and then run gridsome create my-gridsome-site.
However, not sure why installing with npm, doesn't work.
if you install globally like this yarn global add #gridsome/cli
you need to add this on your path in .zshrc if you use zsh
~/.yarn/bin
here's my .zshrc config in the last line, focus on the GLOBAL one
export TWEEGO=$HOME/DEV/TWINE/tweego
export ANDROID_SDK=$HOME/Library/Android/sdk
export GLOBAL=$HOME/.yarn/bin
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$TWEEGO:$GLOBAL:$PATH

Built stuck at 0.0% while bundling index.ios.js

I don't know exactly why but all my react-native projects cannot build anymore today and I'm stuck with a the Bundling of index.ios.js at 0.0%.
I tried a couple of things but all my projects got the same issue.
NOTE: This workaround is for macOS.
Found out that the culprit was watchman 4.7.0.
My issues started after having upgraded to watchman 4.7.0 using brew.
Looks like there's an issue in this new version of watchman:
watchman issues 358.
At the end I solved my issue removing the content of the /usr/local/var/run/watchman/ folder.
I tried several things: the above answer, launchctl unload, restart, reinstall... You name it. Here's how I fixed it on MacOS:
TL;DR: Remove brew version and follow official documentation to compile from source. Use flags on configure: --enable-statedir=$HOME/.watchman --without-python --without-pcre
Reasoning: I don't need python bindings. I also suspect some permission issues and thought using my home would be safer than default path.
steps:
brew rm watchman
(just to be safe) launchctl unload -F ~/Library/LaunchAgents/com.github.facebook.watchman.plist
(just to be safe) restart mac
git clone https://github.com/facebook/watchman.git
cd watchman
git checkout v4.9.0 // Prefer lastest version here.
brew install autoconf automake libtool // Compilation tools
./autogen.sh
./configure --enable-statedir="$HOME/.watchman" --without-python --without-pcre
make // Wait... It'll compile the .o files
make install // If it fails try with sudo but it shouldn't.
After make install it should be in your path here: /usr/local/bin/watchman
Try to watchman version or something. Try to see if it fixed your problem.
Keep in mind most people have their stuff in /usr/local/var/run/watchman/. Our equivalent is now ~/.watchman/
Let me know if this helps you. :)
run the following command
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
This also may happen in case your node dependencies are not installed, e.g. node-modules/ in .gitignore and repo is freshly-pulled.
In this case, your should do npm install of yarn (in case you are using yarn).

Homebrew - repeated "linking" bug. What is the underlying issue here?

So I've been using homebrew to install various packages/libraries/programs on my mac. I keep running into a problem in which homebrew tells me that I have unlinked kegs in my Cellar.
For instance, upon running brew install phantomjs I received the following message:
Warning: Could not link phantomjs. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link phantomjs'
Possible conflicting files are:
/usr/local/bin/phantomjs -> /usr/local/lib/node_modules/phantomjs/bin/phantomjs
I tried running brew link phantomjs as recommended, and hit a similar problem:
Error: Could not symlink file: /usr/local/Cellar/phantomjs/1.9.2/bin/phantomjs
Target /usr/local/bin/phantomjs already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name
The command brew link --overwrite --dry-run phantomjs gives the following message:
Would remove:
/usr/local/bin/phantomjs -> /usr/local/lib/node_modules/phantomjs/bin/phantomjs
I will probably go ahead and overwrite, but this appears to happen every time I try to install something with homebrew. Why? Why isn't homebrew working as expected?
Thanks.
From what I can tell, looks like you have previously done:
% sudo npm install -g phantomjs
In this case, you should do the following:
% sudo npm uninstall -g phantomjs
% brew link --overwrite phantomjs
I thought I'd take a crack at this. I ran into a similar problem today, and I think it may be related to this:
https://github.com/Homebrew/homebrew/issues/22408
Long story short, I think it has to do with how npm manages packages vs how brew does it. (I'm assuming you installed node with its defaults, which would have given you npm).
At some point you probably installed some package with npm. Maybe grunt, karma, etc..those by default end up in /usr/local/lib/node_modules.
Maybe one of those packages or its dependencies(or sub-dependencies) depended on phantomjs (I think Karma might use phantomjs?) Anyways, if now you are trying to brew install phantomjs, which is trying to make a symlink to it, that may be conflicting with the already existing symlink that npm created for you..
I think you can change the symlink path for that package so that brew permanently points to that already installed package in the node_modules folder. Sorry not to be more specific, I'm just figuring this out myself.

Prevent warning about Macports/Fink installation

How can I prevent the following warning from Homebrew appearing whenever I install something?
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Note that I've never (that I recall) installed Fink on this machine and I just uninstalled Macports. I've tried removing /opt/local/bin from my PATH to no avail.
Did you follow the official guide? (specially the "rm" part)
Looking at the source (in def macports_or_fink_installed?), it seems to check something like this:
$ which port
$ which fink
$ ls /sw/bin/fink /opt/local/bin/port # if they exist
$ ls -ld /sw /opt/local # if either directory exists it must be readable
It's a dirty hack but if you just want to silence the warning you can comment out the relevant parts of check_macports in $(brew --prefix)/Library/Homebrew/cmd/install.rb.

Resources