Linux installation Node.js (in Deepin example) suitable for Debain based
Step
1. Access NodeJs official website to download the file:
Open the terminal used cd Downloads
to enter the 下载
folder ~
3. command, the compressed file to a /usr/local/salt
folder:
tar xf node-v14.15.0-linux-x64.tar.xz -C /usr/local/salt/
salt
(Salt) is a folder I created to store the programming environment. If you fully understand the command line and folder structure, you can remove the salt folder, otherwise, just copy and paste my commands to complete the installation~
3. In Use the terminal to cd /usr/local/salt
enter the /usr/local/salt
folder, and then run the following command:
mv node-v14.15.0-linux-x64 nodejs
This command can be simply interpreted as renaming the purpose of the lengthy folder name to rename tonodejs
ls #此命令可以查看当前文件夹下的所有的文件以及文件夹,可以检查一下是否出现了nodejs文件夹
5. Execute the cd nodejs
command and enter the nodejs folder (many tutorials in the next step suggest copy and paste, but it is recommended to use soft links directly, which is more convenient and will not damage the structure of the file).
Execute the following two commands in sequence:
ln -s /usr/local/salt/nodejs/bin/node /usr/local/bin
ln -s /usr/local/salt/nodejs/bin/npm /usr/local/bin
These two commands are to /usr/local/bin
create two soft links under the folder. The functions of these two soft links are similar Windows
to desktop shortcuts. Place the commands in this folder and you can execute them globally (that is, you can use node at any location and npm)
6. executed twice in a row cd ..
to fall back to local
folder, use cd bin
to enter local
in the bin
directory, use the ls
command to see if there is npm
the node
file, as if prompted, then success:
7. in any position, execution node -v
or npm -v
, if there is the version information , The installation is successful, as follows:
8. ---------------------------------------Uninstall- --------------------------------------
1. Go to thesalt
folder, use the following command to delete the nodejs
file folder ( -rf
to remove a folder, without -rf
only delete files or compressed files, etc.):
rm -rf nodejs
2. Enter the /usr/local/bin
folder, use the following command to delete npm
andnode
rm node
rm npm
3. Uninstallation is complete
9. -------------------------------------Install cnpm----- --------------------------------
1. Chinese people use their own npm to use peace of mind, use comfort, and use rest assured ,Excuting an order:
npm install -g cnpm --registry=https://registry.npm.taobao.org
2. When the following prompt appears, the installation is successful:
If there is no above prompt, or prompt Error
, use Ctrl
+ to C
exit, and then perform several more times.
3. At this time, the cnpm command is still not available. Like node & npm, to create a soft connection, execute the following command:
ln -s /usr/local/salt/nodejs/bin/cnpm /usr/local/bin
Note: The salt
(salt) folder in the first address on the left is created by myself and used to store the environment. You can choose by yourself.
4. Enter the command in the terminal (any position):, cnpm -version
if the following content appears, the installation is successful:
5. If it is bash:cnpm:command not found
or bash:cnpm :未找到命令
, delete the one in the /usr/local/bin
directory cnpm
, re-create the link, and check whether the soft link command is missing -s
.
The above picture is the prompt of the installation error, because I have less time to create the soft link, and I can -s
execute the delete command rm /usr/local/bin/cnpm
.
Update: One-click installation-git:
sudo apt-get install git