Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration method of nodejs Development Environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "the configuration method of nodejs development environment". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Nodejs version upgrade is quite fast, there are more or less differences between different versions, when switching versions, if you do not use version management tools, you need to uninstall and then install a new version, wasting unnecessary time and energy. How can you stand it as an efficient programmer?

Nvm as a nodejs version management tool, through the command line switch, to install and use multiple nodejs versions in the development environment.

For windows and linux two different operating systems, nvm installation methods are also different, let's introduce them respectively.

[installation of nvm under windows system]

Step 1: download the nvm software first.

(address: https://github.com/coreybutler/nvm-windows; or search nvm directly in github, as shown in the following figure. )

Download the version selected in the red box (version 1.1.6 is used as a demonstration in this article).

Step 2: create a dev folder under the root of disk C, and create two new folders under this folder-nvm and nodejs.

Step 3: extract the compressed package downloaded in step 1 to get the files shown in the figure, and then copy the 5 files to the nvm folder established in step 2.

Step 4: after the mouse selects the install.cmd file, right-click to run as an administrator.

Step 5: a settings.txt file will be generated at this time, depending on the version of your computer system, the location and content of the file will be different. To unify the configuration, move the generated settings.txt to the nvm directory (or manually create a new settings.txt), which is as follows:

Root: C:\ dev\ nvm

Path: C:\ dev\ nodejs

Arch: 64

Proxy: none

The final configuration results are as follows:

Step 6: configure environment variables.

Operation procedure: right-click "my computer"-click "Properties"-Click "Advanced system Settings"-click "Environment variables". In the following "coefficient variables", if NVM_HOME and NVM_SYMLINK do not already exist, then create a new one and pay attention to the setting of the variable value; if NVM_HOME and NVM_SYMLINK already exist, edit the variable value and set the variable value.

The variable value of NVM_HOME is: C:\ dev\ nvm

The variable value of NVM_SYMLINK is: C:\ dev\ nodejs

In [system variable], select [path]-Click "Edit"-add "NVM_HOME and NVM_SYMLINK" in the middle of the%% package at the end of the variable value, and use ";" as shown in the figure:

Then, run nvm-- version on the command line, and the following output indicates that the installation is successful.

[nvm installation under linux system]

Step 1: download again, search nvm in github as shown in the figure:

Click the link to enter the page and you can see two download methods: curl and wget:

You can choose any download method. When one of these commands is executed on the linux command line, nvm is downloaded by default, and environment variables are added by default. As shown in the figure:

Step 2: because the environment variable has been modified in linux, you must also source it to take effect-- run this command on the command line:

Source / .bashrc

This allows you to use nvm on the command line of linux. It can be seen that compared with the windows system, the development and configuration under the linux system is much more convenient.

Finally, I will introduce some common commands of nvm:

Nvm install x.x.x (nodejs version number) install the corresponding version of nodejs

Nvm ls lists all nodejs versions of the machine

Nvm use x.x.x switches to the corresponding version of nodejs

This is the end of the content of "how to configure the nodejs Development Environment". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report