The difference between nvm and volta for node version control

        Preface - We all need the node.js environment for front-end development. Can we directly install the specified version? Yes, you just have to uninstall and reinstall when you need to change versions. Is there a tool that can help us change the node version without uninstalling it? Yes, nvm can do it. So is there any tool that can automatically change the node version without us having to switch manually? The answer is yes, volta can do it!

1. node.js

Node.js is a server running environment for the JavaScript language.

Node.js is JavaScript running on the server side.
Node.js is a platform built on the Chrome JavaScript runtime.
Node.js is an event-driven I/O server-side JavaScript environment based on Google's V8 engine. The V8 engine executes Javascript very quickly and has very good performance.

2. nvm

1.What is nvm

        nvm, also called node.js version management in English, is a nodejs version management tool. nvm and n are both node.js version management tools. In order to solve the incompatibility of various node.js versions, you can use them to install and switch different versions of node.js.

2. Install nvm

        Download link—— https://nvm.uihtm.com/nvm-1.1.10-setup.zip

        (1) After uninstalling the previous node, install nvm , nvm-setup.exe installation version, and run nvm-setup.exe directly.

        (2) Select the nvm installation path

        (3) Select nodejs path

        (4) Confirm the installation

        (5) Confirmation after installation

        Open CMD and enter the command  nvm . If the installation is successful, it will be displayed as follows. You can see that various commands are listed in it. The Chinese instructions for these commands will be listed at the end of this section.

3. Use nvm to install node.js

         (1) nvm list available Display a partial list of downloadable versions

        (2) nvm install latestInstall the latest version (you can see the corresponding version numbers of node.js and npm above during installation. It is not recommended to install the latest version)

        (3) nvm install Version number installs the specified version of nodejs

4. View the installed version

    nvm listOr nvm lscheck the currently installed version (there is no * in front of the current version number, and no version is used at this time, and an error will be reported when using node.js)

5. Switch node version

    nvm useThe version number uses the specified version of nodejs (at this time, you will find that there is a * mark in front of the enabled node version, then you can use node.js)

3. volta

1.What does volta do?

        Volta's job is to manage your JavaScript command line tools, such as node, npm, yarn, or executables provided as part of a JavaScript package.

        Similar to a package manager, Volta keeps track of what projects you're working on (if any) based on your current directory. When you are in a project that uses a specific version of a tool, the tools in the Volta toolchain automatically detect and take care of routing you to the correct version of the tool.

2. Download and use of volta

To download volta for Windows, click the link to download and install it directly: https://github.com/volta-cli/volta/releases/download/v1.1.1/volta-1.1.1-windows-x86_64.msi

         After the installation is completed, if the node version installed on our computer is 14.19.0, but when we start a project, the node version in its package.json file is 14.15.5, we do not need to perform any operations at this time , we open the terminal in the project and enter node -v. The version displayed is 14.15.5. This is the magic of volta!

Guess you like

Origin blog.csdn.net/gkx19898993699/article/details/132578951