Node.js and Git installation and environment configuration
Off-topic: the computer hard disk collapsed, can only return to the factory to change the hard disk, need to rebuild the blog environment, encountered some problems also have a new experience, in this blog, write clearly I set up the whole process,. Note: if the computer looks like the picture, (picture) must not move, restart not even, wait for his own recovery to 100 percent, to 100 percent and then restart, otherwise the consequences may be like me hard disk collapse, deal with much trouble.
I referred to these two articles throughout my blog building process, including my own Hexo Blog tutorial (Windows), hexo Blog Static Framework tutorial and pit in operation. Thanks to all the authors whose articles I referenced.
Install Node.js on Windows and configure the environment
The link I used to install it was this: Node.js
Download the node. Js
Url nodejs.org/zh-cn/downl…
Normal installation (default is Add to PATH), you can change the installation address (can not be C drive, remember this address).
Automatically install the necessary tools. Note that this will Automatically install the necessary tools. Do not select this option. Proceed to the next step until the installation is complete.
After the installation, open the terminal (WIN +R) and enter CMD. Enter node -v and NPM -v in the terminal. If the installation is successful, the version number is displayed normally.
Configure the environment
NodeJS and NPM cannot be used directly after being installed. By default, NPM installed modules are not installed in the NodeJS program directory, such as the D disk I set up when installing, “D:\ node_js/installation”, And we use NPM to install a cluster module he will appear below the default path on disk C, so, if we don’t modify the NPM module installation directory, then it will be installed by default, here as you test development a variety of different projects, installation of the module is more and more, the volume of this folder will be more and more big, Until it fills up your C drive. So we need to modify the configuration of NPM.
1 Create two new folders named node_cache and node_global in the installation address (these are used to store the cache files of the installation process and the final module configuration location).
2 Run the following commands in the CMD window:
NPM config set prefix “D:\node_js\installation \node_global
NPM config set cache” D:\node_js\installation \node_cache
This is to configure NPM’s global module directory and cache directory to the two directories we just created.
3. Then open the CMD interface and install the cluster module using the following command:
npm install cluster -g
Open the node_global directory you just created and see that the cluster directory is now installed under this directory.
4 Then we configure the NPM environment variables and nodeJS environment variables. Right-click on the computer icon, select properties, and then click Advanced System Configuration. There is an environment path in the lower right corner of the new window that pops up. Click Go, and you can see the configuration interface of environment path. Then in the window that pops up, fill in the variable name: NODE_PATH
The variable value is: D:\node_js\installation \node_modules\
After filling in, click OK, and you will see our configured NPM environment PATH.
5 You need to modify some default nodejs module invocation paths, because the module installation location is changed, if the nodejs command is returned to the original location, you will not find the installed module.
In the environment variables window, select Path, then click edit in the lower right corner, and select the NPM one. Click edit on the right and change it to: E, then click OK to save the configuration.
6 At this point all the configuration work is completed, then open a new CMD window. Enter the command:
node
Go to nodeJS’s interactive command console and type:
require(‘cluster’)
If information about the Cluster module can be displayed, all the preceding configurations take effect.
7 The last thing we need to do is to change the NPM module download repository from the default foreign site to the domestic site, so that the speed of module download can be relatively fast, just need a command, the command is:
npm –registry registry.npm.taobao.org install cluster
The command above is to temporarily install the Cluster module using the address of a domestic NPM source.
If you want to always use the source address, you can use the following command to configure it.
npm install -g cnpm –registry=registry_url
Registry_url refers to a number of NPM warehouse addresses provided in China, commonly used are:
registry.npm.taobao.org
r.cnpmjs.org/
You can use either of these.
At this point, nodeJS and NPM are all configured on Windows.
Install Git and configure the environment
See Git for the following
Download link git-scm.com/download
Normal installation after downloading, which will encounter the following need to check the place
The rest is all defaults
After the installation, the desktop right button has these two small ICONS
CTRL + R, and then enter CMD and press enter in the pop-up box, enter git and press enter, a bunch of information will appear, indicating that the installation is successful, generally all the above is very smooth.
Environment configuration
Create a GitHub account, github.com/, and click on the desktop… Git Bash Here (Git Bash Here)
2 Set the user name and enter the user name in the displayed dialog box
Git config –global user.name “username” //
Configure your email
Git config –global user.email “[email protected]” //
After the preceding command is executed, run the git config –global –list command to check whether the configuration is OK
3 generating SSH
Continue typing in that box
ssh-keygen -t rsa
Then you need to press enter three times, then go to the system disk directory (usually in C:\Users\ your username.ssh) (MAC: /Users/ user /.ssh) to check whether there is any. An SSH folder is generated with the following two files in this folder
4 Add the public key (ID_rsa.pub) in the SSH folder to the GitHub management platform, and locate the following page in the GitHub personal account Settings
Title Copy and paste the contents of the public key (id_rsa.pub) file into the key (note: copy and paste all contents, including ssh-rsa), and click Ass SSH key
5 Run the following command in the Git Bush command box to check whether the configuration is successful
ssh -T [email protected]
If the following information is displayed, the configuration is successful