How to Switch Between Node Versions in Visual Studio Code using Node Version Manager (nvm)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] welcome to a new video so I was gonna start my series on how to create a next GIS app and then I just ran into a problem so I thought it would be a good idea just to troubleshoot it and maybe other people have the same problem and we can all solve it together so this is an xcis app and the problem is with the packages installed with the node that you're using so I'm just going to run this app so there is nothing fancy I'm assuming you already have your app and you just want to run it so let's just run it to see what we get so if you get this kind of problem that says the syntax error and then it gives you like you know the question mark is giving you this error or something like that it's because you're using an outdated uh node package at least for me that's the problem that I've come to know so if you want to know which one you're using you can issue the following command which is NVM current and as you can see we're using the default one which is the 12.22.7 and if you want to select which ones I know I have installed the latest one because I installed it before by by doing NVM install and then you know the version that you want whatever it is right so I already did that so I just want to see a list of the ones that I have installed here so to do that you can just issue the following command which is NVM list LS so that's going to tell you uh the packages that you have here so let me just make this bigger it tells you like the packages that you have and as you can see the default one is pointing to the 12.22.7 so every time you open Visual Studio it's gonna use that one right so I want to use the latest one so as you can see I have a bunch of them installed so let's say that I want to use the the latest one so what would I do to do that so to do that you can issue the following command which is NVM NVM use and then use the version of the package right in my case uh 19.8.1 all right so let's just run it nothing is going to happen so now it tells you like you're using that one and you can double check but just issue in the command name VM current once again and it tells you that that's the one that you're using right so then you can uh you can run the app so let's just run the app npm run Dev so now it's going to run no problem so you can see it's running no problem all right so what happens when we close Visual Studio let's just close it open Visual Studio again I'm just going to open the same pro project that I was using let's just give it a second it's initializing so once we get here so let me I just have to CD into my project npm run Dev and you can see that I got the same problem that I was getting before so it just defaulted to the to the version 12 uh whatever it is let's just check which one it was if you issue that command it's going to tell you like oh you're using this one as the default one but remember that we already changed it to the 19.8.1 so to change it permanently and so that it when you close visual studio and then you open it again you'll have the latest version or the one that you're gonna set as the default one as the latest one you have to issue the following command so let me just clear this you have to issue the following command NVM alias default and then the version that you want so in this case uh this is the latest I think so we just issue this command and now you can see that the default one has changed to that one so let's just uh see which one we're using uh it says that we're still using 12.22.7 all right so but then let's just do LS the default one is going to be that one but the one that's pointing here is that one but like let me just say NVM use then let's just uh do this one MVM use and then the version Ray so now that's going to change it so now it says that you're using that one and let's see yeah so now we're using that one and the default one is that one the latest one so now let's close visual studio so now we will run the app it's gonna run but let's close visual studio and open it again and now the default one is going to be the latest and it's not gonna default to the to this one here so let's just try that so let's just close visual studio and let's open it again all right so this is the third time that we've opened visual studio so let's just see which versions uh we have and as you can see this one the 12.22.7 is not the default one anymore so now we have the latest as the default one so now let's use uh issue this command just to double check and as a matter of fact we're using the latest now and that's because uh we needed to restart Visual Studio to to make the changes propagate so now we say npm run Dev that should work immediately and then we won't have to change it anymore and that that has saved us a lot of time so now we don't have to you know keep using NVM use and then just switch them back and forth between versions if you want to you can set the default as a different one I just remember that the command is uh NVM Alias default and then the version that you want and then you have to restart visual studio and that would set that version to the default one the next time that you open Visual Studio so this is just a quick tutorial on how to troubleshoot that error if you get it and yeah I just wanted to make this video maybe some people will see it and it will be useful for them if you like the video just give it a thumbs up leave a like leave a comment and I'll see you on the next one thank you foreign thank you
Info
Channel: Bryam Loaiza
Views: 6,529
Rating: undefined out of 5
Keywords:
Id: hNPKx6UOpMg
Channel Id: undefined
Length: 6min 9sec (369 seconds)
Published: Sun May 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.