DEV Community

Cover image for Tips and tricks to set up your Apple M1 for development
Chris Gradwohl for Courier

Posted on • Updated on • Originally published at courier.com

Tips and tricks to set up your Apple M1 for development

I recently joined Courier as a Software Engineer and part of the onboarding process was to set up and configure my development environment on the new M1 MacBook Pro. This task was more complicated than usual because, with the new MacBooks, Apple has replaced their long-running Intel processors with their own M1 chip. To help you take full advantage of the power of the new MacBooks, here are some tips and tricks I picked up when setting up my own machine.

Rosetta vs Native Terminal

Command line tools are crucial for our day-to-day workflows. However, several critical CLI tools like nvm and brew do not have native versions built for the new M1 architecture, so installing them on your native terminal can be frustrating.

Thankfully, with Apple's translation layer Rosetta 2, we can easily download and compile applications that were built for x86_64 and run them on Apple Silicon. I’ll explain how to duplicate the macOS native terminal and force the duplicated terminal to always run with Rosetta 2. Using this "Rosetta" terminal makes it a breeze to install our preferred tools.

1. Create a Rosetta Terminal

First, duplicate the Terminal and rename it.Then,Open Finder and navigate to the Application/Utilities folder and select "Duplicate."

Duplicate your terminal on Apple M1 MacBook

Rename this new terminal to something like "Rosetta-Terminal.".Now right-click on your new Rosetta Terminal and click "Get info."

Rosetta-Terminal Context Menu

From the “Get info” menu, select "Open using Rosetta."

Rosetta-Terminal Get Info

Now we have a special terminal that can be used to install our command line tools. During the install, they will be translated by Rosetta. After the install, we can use them from the native terminal.

2. Install your tools with the Rosetta Terminal

Let’s install some tools! Now that we have a dedicated Rosetta Terminal, we can install our CLI tools just like we would on an Intel MacBook. In this case, I’m going to install nvm, but it’s the same process for any other CLI tool you may need, e.g. Homebrew, AWS CLI, etc.

First, open up "Rosetta-Terminal" using Spotlight (just hit Cmd+Space).

Spotlight Search Rosetta-Terminal

Confirm that you are using a Rosetta Terminal by entering the arch command, which should return i386.

Terminal Arch command

Next, install nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

And then install your preferred node.js version. I'll be using version 12.x

nvm install 12
Enter fullscreen mode Exit fullscreen mode

Now, open up the Native Terminal with Spotlight:

Spotlight Search Terminal

Confirm that you are using the Native Terminal by typing the arch command, which should return arm64. While you are here, you can also validate the installation.

Terminal Tool Versions

As you can see, nvm, npm and node.js version 12.x have all been successfully translated and installed on Apple Silicon. 🎉

I recommend using the "Rosetta-Terminal" for installing the rest of your command line tools and using the Native Terminal for your daily workflow.

Finding and installing native applications

Right now, there are still a few applications that don't offer full native support for Apple Silicon. So we have to install the x86_64 versions of these applications. This means that Rosetta will run in the background to translate the application and make it compatible to run on the M1, but this also means that it will not run in its fully ARM optimized glory.

Before you install the rest of your applications, I recommend checking if they offer native support for Apple Silicon. Sometimes, a fully ARM native version is not available, but an ARM optimized beta version is. You can visit the website “Does it ARM?” or Is Apple silicon ready? and search for any app. It’s a great resource to find and install Apple Silicon versions of your apps.

Installing VS Code Insiders (beta)

For example, this is what I see when I search for VS Code:

DoesItARM VS Code

Currently, VS Code does not fully support a native Apple Silicon version of their software. But they do support a beta release version called Insiders with native support! If you want to try it out, head over to VSCode Insiders. Remember to select the ARM64 version of the application on the download page.

VS Code Insiders

After installation, open up Visual Studio Code - Insiders (and behold the blazing speed of the M1 🚀), enter cmd+shift+p to open up the Command Palette and install the 'code-insiders' command into your bash PATH.

VS Code Install CLT

After that’s installed, you can open up files with VS Code from your terminal using the code-insiders command. But since nobody has time for that many keystrokes, add this alias to your zshrc or equivalent:

alias code="code-insiders"
Enter fullscreen mode Exit fullscreen mode

Restart your terminal and now you can open up files using the code command – like a boss. 😎


Other apps are not this difficult to find an Apple Silicon native version. For example, Chrome offers a fully supported ARM64 version of there software:

DoesItARM Chrome

On the Chrome download page, make sure to select the version for "Mac with Apple Chip"

Select Chrome Version

Final tip: Checking your app version

At the time of this writing most applications do offer fully supported ARM64 versions of their software, but a few (like VS Code, Node Version Manager (nvm) and Homebrew) still do not. Over time we should expect to see fully supported Apple Silicon versions of our favorite apps.

As you install applications on your new MacBook, you might notice that some auto-update to the new architecture, while others do not. For example, I noticed that Chrome auto-updated to a x86_64 version. If you suspect that one of your apps is running an older version, you can check the Activity Monitor and see what type is running on your machine:

Activity Monitor


I hope you find these tips helpful! If you have any additional tips or questions about how I set up my M1, don’t hesitate to reach out!

Also you can find out more about where I work at Courier

Top comments (18)

Collapse
 
thatguysam profile image
Sam Carlton

Hey, Does It ARM is the site I built.

I'm glad you're getting some healthy use out of it.

Collapse
 
suhasdeshpande profile image
Suhas Deshpande • Edited

This was life saver. I must add if everything goes south, which it went in my case, I had to factory reset the computer, that didn't fix things either because I got struck in account creation.

You would need a spare macbook of any kind and use Apple Configurator

forums.macrumors.com/threads/insta...

Collapse
 
tashsensei profile image
Tash Sensei

keep receiving this error when i pasted your curl command in my rosetta terminal
zsh: parse error near `)'

curl -o- [raw.githubusercontent.com/nvm-sh/n...](raw.githubusercontent.com/nvm-sh/n...) | bash

Collapse
 
cgradwohl profile image
Chris Gradwohl

Hey Tash, good catch!

I just updated the post with the correct curl command. Thank you!

Collapse
 
nmsand profile image
Nat Sandoval

I also recently joined Courier; I was very excited to receive a brand new MacBook with an M1 Chip! I did, however, run into a bit more problems than Chris. I decided to install Xcode from the App Store, instead of terminal, since I was already downloading slack and other apps from there. Somehow, this seems to have goofed up my setup. Despite following Chris' advice when setting up my environment, bundling for serverless deployment seemed to freeze! Uninstalling Xcode and attempting to reinstall it through terminal also didn't work, that froze too! All advice found was to factory reset my computer.
The factory reset process for the M1 chip is a bit different, instead of the command-R during startup, you must hold the power button until you see "Loading Start-up Options", then you wipe your disk as usual and attempt to reinstall your OS. Unfortunately I ran into a problem when doing that as well. It seems to be common with M1 chips, even though it's not supposed to happen with Big Sur 11.01, that during reinstall you get an error that says something along the lines of "Cannot personalize Software"; your MacBook M1 turns into sleek and beautiful brick… This is where another Mac and app configurator 2 come into play.
Download app configurator 2 into your second Mac and begin connecting. You must connect your second MacBook to power, and using your new Mac's apple cable (must deliver power and data) connect it to your beautiful brick. (Note: You must use your M1s thunderbolt port that is closest to the back, otherwise it will not be recognized by app configurator 2). Press and hold your M1s power button. At the same time, hold the right shift key, the left option key, and the left control key for EXACTLY 10 seconds (otherwise it will not appear in configurator 2) let go of the keys and continue holding the power button. Your M1 will not have any sort of reaction, but it will appear in app configurator 2. Select it, click actions, restore. Make sure you don't lose power during restore to either Mac, wait for restore to be completed, then set up your Mac again. Install Xcode from terminal (I specifically tried to use git command, and just accepted when it asked me to install Xcode.) Follow Chris' instructions and enjoy your Mac!

Collapse
 
jamiesauve profile image
Jamie Sauve

Thanks for the article :) I'm trying to set up a Mac Mini M1 as my personal computer and running into some grief. I can follow the steps above to create a Rosetta terminal, and I can install nvm; but the regular iTerm can't find it after that - and if I close the Rosetta terminal and start it up again, it also says nvm isn't a thing. It's like I'm only installing it for the current session or something.
...but if I do install nvm, it says it's already installed, and suddenly it knows which version of node and npm I have installed.
And if I close the terminal, it loses its memory again.
Any idea what's happening?

fwiw, I'm using zsh.

Collapse
 
cgradwohl profile image
Chris Gradwohl

Hey Jamie!

I have not used iTerm for this article, but I downloaded it and can confirm that it is not working as you have described.

Can you try to use the regular Terminal application that comes with your mac for the nvm installation? After installing nvm with the Terminal application (not iTerm), you should be able to use nvm on the terminal client of your choice.

Let me know if this works!

Collapse
 
tnanhpt profile image
Anh Pham

great! thank you very much

Collapse
 
cgradwohl profile image
Chris Gradwohl • Edited

you're very welcome! How are you liking the new M1?!

Collapse
 
petrosvoivontascp profile image
petrosvoivontas-cp

This is a bit misleading. Just because arch prints arm64, doesn't mean that node will run using this architecture. If you install node with x86_64, that is exactly what you get. To verify, try running node -p process.arch. As you will discover node will use the i386 architecture, because that is what it was installed with.

Collapse
 
cgradwohl profile image
Chris Gradwohl

Thanks for the reply and sorry for the confusion!

In this example node v12 is ONLY available for x86_64 architecture, but installing node with a Rosetta terminal provides an easy way to install and run node on apples arm64 architecture.

Let me know if you have any other questions.

Collapse
 
petrosvoivontascp profile image
petrosvoivontas-cp

No worries. Node v15 is available on arm64, if you don't mind giving up LTS support btw.

Collapse
 
ediri_aghwotu profile image
Aghwotu Ovuoke • Edited

Thank you for writing this! In my case, I installed nvm with homebrew.

Collapse
 
christopher_vivona_910575 profile image
Christopher Vivona

This is what I keep getting when I run it

curl -o- raw.githubusercontent.com/nvm-sh/n... | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 69508 0 --:--:-- --:--:-- --:--:-- 73516
=> nvm is already installed in /Users/christophervivona/.nvm, trying to update using git
=> => Compressing and cleaning up git repository

=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
OR
=> Append the following lines to the correct file yourself:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nv

Collapse
 
kalwiggins profile image
Kal Wiggins

thanks so much!

Collapse
 
cgradwohl profile image
Chris Gradwohl

Absolutely Kal!

Collapse
 
amouratoglou profile image
Agustin Mouratoglou • Edited

thanks !!!

Collapse
 
jonesau profile image
Jonesau

刚好遇到这个问题,感谢大佬