How to install Node and NPM on the M1 Mac or Linux with NVM

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
well hello there i am going to be installing node on this apple m1 macbook you know since the upcoming macbook pros are about to be released i'm sure that many more people are going to be making the transition to apple silicon and one of the cool things is that because this transition is already over a year old many tools have already jumped ship to the apple silicon architecture node is already something that already supported the arm architectures their transition to apple silicon wasn't that you know it wasn't that big of a leap since they already supported arm systems and remember node.js is just a runtime that allows javascript to be executed in the computer itself and it also comes with the node package manager which is basically used for anything javascript related unless you use yarn and i think you might need node even to install yarn right now we're going to open up the terminal in the terminal as you can see it is default it's just a black and white terminal but what i want to do is i want to install node.js let's open up the browser and then let's go and find the instruction in order to install node we are actually going to install nvm nvm stands for the node version manager one of the problems when you install node is that node may install in a location that requires administrator privileges and we don't want that see whenever you run an npm command whenever you do anything related to node you never want to use sudo what happens when you install node normally is that it goes into a directory that requires root privileges and you have to run that command with sudo what node version manager does is that it install everything for you in the correct path in addition to that it then makes it a little bit easier by being able to switch between node versions so if you're currently working on a project that requires node version 12 you can and you have globally installed node package manager or anything over 15 but it requires 12 to work properly you can easily switch between node versions so not only does it make the installation a little bit easier but it makes everything more compatible in the long run if we go to this github repo you it's called nvm sh no version manager what we want to do is we want to go to install instructions and we want to do it from source oh i forgot something uh natural scrolling is on and i hate that there it is so in order to install node version manager it's super simple you use this curl command and you open up your terminal and you paste it and that's it you now have nvm installed so if you type nvm oh that's right it's not going to work because we need to add this to our zshrc profile that is super simple the only thing you have to do is highlight this click copy and then type ls dash a and it will list all the directories in your home directory so right now we're taking a look at the home directory and as you can see we have csh history csh sessions but no cshrc i guess we have to create it manually to do that we do touch dot c s h r c now that we click touch we do ls sorry ls dash a and the dot cshrc profile has been created we can run we can run that command once again the curl command and it's going to automatically add it to the cshrc so if we go source dot c z shrc what it's going to do is that is going to um it's basically like a refresh so that it knows that nvm has already been installed now if i type nvm i have it installed and you get to see all the nvm commands let me make this a little bit bigger and then command plus to make it to zoom in a little bit i know this isn't a very intuitive terminal after this video i am going to show you how to install power level 10k themes and oh my csh nvm has already been installed and what nvm does is just it manages the versions of node and it will also install them for you now the nvm is installed the only thing you have to do is mvm installed node and it will install the latest version 16.11.1 and it will also install the mpm as well now that is downloaded you just have to tell it to use it so you can type nvm use node and there you go node has been installed so if i type node dash dash version node version 16.11.1 and if i type npm dash dash version we have npm version 8. so node has been properly installed so if you click i keep saying click but if you type ls-a this is your home directory right you will be able to see an nvm folder and this is where node is installed so if we see the into dot nvm and click ls once again you will see there's a directory over here with versions if we cd into versions we see another directory for node so if we cd into node you will see version 16.11.1 now let's say that we want to use another version let's say we want to use an lts release which is which usually lags behind the current release well you can type mvm install dash dash lts and that is the same instruction that you find up here so clicking that or typing that what it will do is that it will install the lts release which i believe is version 14. now for version 14 you might need rosetta for it to run on the apple m1 but right now all it's doing is downloading it and i believe it's also going to compile it so this might take a second i'll be right back once it does good news it finally installed this took a lot longer than i expected but what it did was is that it build the node software from source i wasn't expecting this but one of the one of the good things is that it already has an arm version so if a lot of the things that it did is compile the arm version of node and to use node 14 you don't necessarily need rosetta so if we tell it to use the long term release with nvm use dash dash lts see it now says that i'm using version 14.18.1 and if we go into node dash dash version that's the version that shows up if we go into npm dash version i know you can do dash v but for the people that are beginning i just want them to know you know we're typing out version and as you can see the latest release is version 8 for mpm and the long term release is version 6. so how do we go back you know we want to use the latest and greatest that is simple with nvm you just type nvm use node or sorry you have to tell it to use the version so use 16 and now we switch back to 16.11.1 and mpm also switch so if we go into mpm version now we're back to version 8. one of the cool things is that whenever you install something using a version of node it is saved to that version so if i install something to um to node 16 and then i switch back to version 12 whatever i installed with 16 stays within 16 so you can always start fresh it's just another way that node version manager is super awesome also these instructions work exactly the same for linux i forgot to mention that at the beginning so i'm going to title this mac and linux so the next step is i'm going to install all my csh and i'm going to install the 10k power theme because i want to be able to have some color in this terminal not because you know i want to look cool but rather i want to be able to tell things apart as of right now everything in here is just white however whenever you install a theme you can see the directories are going to be a different color from what the files are and the text is
Info
Channel: Code Fallacy
Views: 1,280
Rating: undefined out of 5
Keywords: m1, apple, m1 mac, apple silicon, nodejs, node, npm, nvm, node version manager, how to install node, macbook, linux, terminal, node package manager, big sur, unix, macbook air, macbook pro, m1 pro, m1 maxx, developer, javascript, node npm, yarn, bash, zsh, monterey
Id: LOd0Dx_ZrYQ
Channel Id: undefined
Length: 10min 22sec (622 seconds)
Published: Tue Oct 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.