Steps to install and use Node.js (win11)

1. System environment

1. System version: Windows 11 Home Edition 64-bit 21H2
2. Node.js: node-v16.13.2-x64.msi

2. Operation steps

1. Download the Node.js version required by the corresponding system. The Node.js official website address is https://nodejs.org/zh-cn/
*Xiaobai can directly click to download, and the official website will automatically match the most suitable version for the current system.
2. Select the installation directory
3. Configure system environment variables
4. Debug npm

3. Download and install Node.js

1. Introduction to Node.js

  • node.js is a JavaScript project management tool, similar in function to maven in java or pip in python.
  • NPM (node ​​package manager) is a package management and distribution tool for node.js.
  • The new version of node.js integrates npm, so there is no need to install npm after installing node.js.

2. Download node.js

  • This tutorial uses the installation package node-v16.13.2-x64.msi
  • Enter the node.js official website and download the recommended node.js installation package
    01_download_1
  • If the current platform cannot be recognized, you can go to the download page to manually select the version to download
    02_download_2

3. Install node.js

  1. Open the installation package node-v16.13.2-x64.msi and click Next.03_install_1
  2. Agree to the terms of use and click Next.
    04_install_2
  3. Modify the installation path
    05_install_3
  4. Select the features that need to be installed, remember to select Add to Path, and then click Next.
    06_install_4
  5. Select optional features as required and click Next.
    07_install_5
  6. Click Install and perform administrator authorization in the pop-up window.
    08_install_6
  7. Click Finish to complete the installation.
    09_install_7
  8. If the optional features are checked in step 5, the following pop-up window will appear after the installation is complete.
    10_install_8

Fourth, the installation is complete and tested

1. Check node and npm versions

Use the following command on the command line to check the version of node and npm.

node -v
npm -v

*Try not to use PowerShell, PowerShell is currently unstable and may report errors.
11_installed_1

2. Node.js directory view

12_installed_2

*5. System environment variable configuration

This step will customize the cache directory and global dependency directory of npm, so this step is optional.

1. Create a cache folder and a global dependency folder

Create two new folders in ideal locations: node_cache and node_global.
13_config_1

2. Use the command line to modify the npm configuration

2.1 Modify npm configuration

Open the command line (recommended) or PowerShell as an administrator, and enter the following statement to modify the npm configuration.

npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"

*The configuration path needs to be changed to your own
14_config_1

2.2 Check configuration npm configuration file

Open the .npmrc file in the C:\Users\username directory to check whether it is consistent with the configuration just now.
15_config_2

2.3 Modify user variables

Enter the system variable configuration, configure the Path variable in the user variable , and add a new variable below . Do not change other variable values ​​in Path.C:\Users\username\AppData\Roaming\npmD:\XXXX\nodejs\node_global
16_config_3

2.4 Modify system variables

Add a system variable in System VariablesNODE_PATH and set the value to D:\XX\nodejs\node_global\node_modules. Add a new value to
17_config_4Path of the system variableD:\XX\nodejs\node_global\node_modules . Do not change other variable values ​​in Path.
17_config_4

Six, the use of npm

6.1 Install plugins using npm

Use the following command to create-react-appinstall the plug-in into the global library. After execution, open the global directory to see the plug-in. --savecommand can add dependencies to the package.json file.

npm install -g --save create-react-app

If it is only used temporarily, it does not need to be installed in the global library, just remove the -g parameter.
19_using_1

6.2 Use npm to uninstall plugins

Use the following command to uninstall the specified plugin, eg create-react-app. If the specified plugin is installed in the global library, the -g parameter needs to be added.

npm uninstall create-react-app
npm uninstall -g create-react-app

20_using_2

6.3 Use npm to install the specified version of the plugin

  • Use the following command to install ramda version 0.26.0.
npm install --save [email protected]

7. References

In the process of learning node, refer to the following literature/video materials

Guess you like

Origin blog.csdn.net/m0_50089886/article/details/122655431