添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Have you ever experience difficulties in software development due to unsupported / different version ? Recently I was facing the same issue. The issue was a different Node.js version from my machine (Node v14.18.0) with my company project repository (Node v10 required). The first solution that instantly pop up in my mind was "I think downgrade my current node by uninstalling it will do the work", But what if you need another version for another project in the near future? Do you want to endure the pain of installing and uninstalling Node.js every time you need a different version of it ?

NVM is a version manager for Node.js, it allows you to quickly install and use different versions of node via the command line.

Let's head to the tutorial !

If you happen to use UNIX, macOS, or WSL (Window Sub-system for Linux), you can install and read the official documentation here

If you happen to use Windows you can install it at NVM for windows which is developed by Corey Butler , download the nvm-setup.zip file.
It is stated that you need to uninstall pre-existing node version, but based on my experience it is not necessary to do so.

After the installation you can open your command prompt and check whether nvm is recognized

C:\Users\YourUsername>nvm -v
Running version 1.1.8.
    Enter fullscreen mode
    Exit fullscreen mode

If nvm is not recognized as internal command or external command, try to re-open your command prompt.

Then, You can type nvm list in order to see list of Node.js version on your machine.

C:\Users\YourUsername>nvm list
  * 14.18.0 (Currently using 64-bit executable)
    10.18.0
    Enter fullscreen mode
    Exit fullscreen mode

If you don't see your desired Node.js version in the list, you can use nvm install command, for example if you want Node.js version 8, you can type nvm install 8.0.0

To use the installed Node.js version you can simply type nvm use 8.0.0

If you see an error message exit status 5: Access is denied., It is due to admin privilege issue. To solve it you can simply run your command prompt as administrator.

Thank you for your time reading this short article / tutorial about Node Version Manager, hope it helps! and Have a great day.

Yes, I once tried to use nvm, but had some problems during the installation, so I tried n and it worked like at charm.

However, once nvm is installed, I guess it works pretty much the same as n.

I love nvm too. Had been using it for many years. Recently I'm also trying out asdf. It's very much like nvm, but supports many other tools as well. I like its .tool-versions file particularly that I can specify the versions for different projects. asdf will choose the correct version automatically when I swtich the project.

Built on Forem — the open source software that powers DEV and other inclusive communities.

Made with love and Ruby on Rails. DEV Community © 2016 - 2024.