1. Enter the official website and select the download version
http://nodejs.cn/download/
2. Installation process
Step 1: Select the next option
Step 2: Check the option to accept the agreement, click the next (next) button:
Step 3: The default installation directory is C:\Program Files\nodejs\, of course you can choose according to your needs Installation directory. Generally, I prefer to install this kind of configuration file in the default location, which is convenient for environment configuration.
Step 4: Here is to choose the mode you want to install. Generally, if there is no special requirement, just choose the first one.
Step 5: Click Install to start installing Node.js.
Installation process:
Click Finish to complete the installation and exit the installation wizard
3. Check whether the installation is successful
After installation, test whether it is successful in the local terminal. If the version number appears, it means success.
node -v
npm -v
(The installation was successful but there was an error)
Modify the npm file to address
Open the folder where nodejs is installed. and open two files npm.cmd and npm
this is my directory
C:\Program Files\nodejs
Find the prefix -g in the 2 files and replace it with prefix --location=global
1. Set the file access permissions, right-click the two folders, select properties, and click edit. Change permissions to full control. Remember that both folders are required.
2. Change the suffix of the second file to .txt, and then open it in Notepad respectively.
3. Replace prefix -g with (Note: Both files are required)
prefix --location=global
4. Check whether it is successful, open a new cmd command line window at this time, win+R, enter cmd, press Enter, enter
npm -v
You can successfully see your version number
4. Configure environment variables
Find your own nodejs installation path and copy it.
Right-click My Computer, click Properties->Advanced System Settings, click Environment Variables
Add the path of nodejs in the system environment variable path
5. Configure the global installation package path
Open the cmd command line window, enter the following command, the path can be specified at will, if the path does not exist, it will be automatically generated
npm config set prefix “C:\Program Files\nodejs\node_global”
npm config set cache “C:\Program Files\nodejs\node_cache”
These two commands need to be executed separately. It may be that the folder cannot be generated because of administrator privileges, so it needs to be created manually.
After manual creation, an error is found, as shown in the figure, and
it is found that the file permissions are not enough. Right-click node, properties => security => Set the full control authority of the users user,
and then the configuration can be successfully opened
Open the environment variable setting window, in the user (or system) variable column, click the "New" button, add a variable name "NODE_PATH", the value is:
C:\Program Files\nodejs\node_modules
In "System Variables", find the Path variable, select it and edit it. Add a value to him:
My Path:
In the "User Variables" column, set the Path variable. If not, create a new one, and set the value to
This nodejs setting is complete, enter node -v and npm -v respectively, and the results shown in the figure below indicate that the nodejs environment configuration is successful.
The following is the solution to the problem of entering npm -v at the end and 'npm' is not an internal or external command, nor is it a runnable program
First enter the path in the environment variable to find the file location of nmp,
open the folder and find that there is no file or only one "etc" file.
After discovering this problem, we should add the path of the npm command line execution file we installed to the environment variable.
Mine is under the "C:\Users\ASUS\nodejs" file.
After the addition is complete, run the npm command immediately.
Thank you for reading here, learning from each other, and communicating and making progress! ! !