How to setup NodeJS, Cocoapods on Big Sur and M1

The general idea is to avoid SUDO as much as possible. Use NVM for node version management. Use rbenv for Ruby management. ZSH being the default shell.

Update: COCOAPODS have issues with M1 and the simplest way to solve this is by opening your terminal in Rosetta mode. This will mean running Homebrew, Cocoapods,Node etc. in x86 mode.

Node(15.x.x) works fine ARM, but if you are running everything else in x86, it makes sense to run node in x86 mode as well.

Open Terminal in x86 Mode (Rosetta)

Open Finder and goto Applications. Look for Terminal and right click on “Get Info”

Enable “Open using Rosetta”

Note: You can prefix all commands with arch -x86_64 to force them to use x86 architecture. I have added it, just to be doubly sure.

Install Homebrew — Requires SUDO

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

If you installed Homebrew and want to uninstall, use the following script:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

Install rbenv to manage Ruby

arch -x86_64 brew install rbenv
arch -x86_64 rbenv install 2.6.3 
arch -x86_64 rbenv global 2.6.3 
arch -x86_64 code ~/.zshrc #nano or any editor
eval "$(rbenv init -)" #add this to profile to run rbenv on start 
arch -x86_64 code ~/.zshrc #nano or any editor
eval "$(rbenv init -)" #add this to profile to run rbenv on start 

Install Cocoapods

arch -x86_64 gem install ffi
arch -x86_64 gem install cocoapods
arch -x86_64 pod install

Install NVM, Node

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | zsh #Reopen terminal
#Install Nodenvm install --lts=fermiumnvm use default

If you want to uninstall nvm and remove node

rm -rf $NVM_DIR ~/.npm ~/.bower