Today I turned out a diary I wrote before installing Node on Linux, today I also share it here, although there are a lot of such articles on the network, but I still want to write a write, maybe write out after there will be big guy can help improve, progress together ~/ byi teeth
First we should have a Linux system to support the rest of our work, using Centos7.0
1. View the Bits of the Linux system
Run uname -r in liunx to see how many bits the system is, and you can see that the one I’m using is 64-bit Linux
2. Download the Node.js installation package
Download address:nodejs.cn/download/
We can see that the download address of many versions is provided here. According to the bits we just checked on our system, we can download the 64-bit installation package
3. Upload to Linux
Download node-v12.13.0-linux-x64.tar.xz file to Linux via FTP. There are many kinds of FTP software, such as XFTP.
4. Decompress the installation package
linux
In thetar.xz
The installation package must be approvedXz - d node - v12.13.0 - Linux - x64. Tar. Xz
To decompress
Tar (child): xz: Cannot exec: No such file or directory xz: yum install xz-y
- You get one the first time you unzip it
The node - v12.13.0 - Linux - x64. Tar
File, which is needed at this timeThe tar xf - node - v12.13.0 - Linux - x64
Decompress the nodeJS software package
5. Install Node
After unpacking the node installation package, you can see a node-v12.13.0-linux-x64 folder in the folder. Use ls to see the /bin folder and CD bin to see the NPM and Node folders
node -v
npm -v
Bash: XXX: command not found bash: XXX: command not found Why? Since you just installed it in the folder you extracted, and now you execute the command outside that folder, you will not find the command. At this time, we need to use the Linux soft link (LN) to link to our file (actually create shortcut), so we need to use the ln command
For example, my node is installed in the root directory
NPM path: ln -s /root/node-v12.13.0-linux-x64/bin/npm I am in the space /usr/local/bin
Node path: ln -s /root/node-v12.13.0-linux-x64/bin/node I am in the space /usr/local/bin
Development:
Ln is another very important command in Linux. Its function is to establish a synchronous link for a file in another location. When we need in different directories, use the same file, we don't need to put in every need directory a file must be the same, we just in a fixed directory, put the file, and then in the other directory with the ln command links (link) it can, need not repeat take up disk space. Ln [parameter][source file or directory][destination file or directory]Copy the code
Finally, you can use NPM -v and node -v anywhere in your Linux to view the version, meaning you can use these two commands anywhere.