DEV Community

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

Tips and tricks to set up your Apple M1 for development

Chris Gradwohl on January 20, 2021

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 n...
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

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