Home > Article > System Tutorial > Download the installation path introduction format of nodejsLinux version
1. Download the nodejsLinux version. Note that this tutorial is in .tar.xz format.
2. Upload to the Linux related path, usually /usr/local/, and execute the following command
xz-dnode-xxxx.tar.xz---Extract tar.xz into a tar file
tar-xvfnode-xxxx.tar---Extract the tar file into a folder
mvnode-xxxnodejs----How to install linux by changing the name of the folder to nodejs
[Check whether the installation is successful and execute node-v in the bin directory]
3. Configure soft connections so that the node command can be used globally
ln-s/usr/local/node/bin/node/usr/bin/node--map node source files to node files under usr/bin
ln-s/usr/local/node/bin/npm/usr/bin/npm
4. Configure /usr/local/src/nodejs/bin to the user environment variable
Switch the current working directory to the user root directory#cd~
View all files, including hidden files#ls-a
Change user environment variable file#vim.bash_profile
Enter i to switch to insert mode, find the PATH variable, and append a comma and the /usr/local/src/nodejs/bin path to the parameter area on one side of it. Press the esc key to exit the output mode, switch to the command mode and enter: wq, save and exit
PATH=$PATH:
:/usr/local/src/nodejs/bin. . . . . . . .
Immediately execute this modification#source.bash_profile
Globally install module n
npm i -g n
View the help documentation of n template
If the user environment variable is configured successfully, you can view the help document of the n template, otherwise an error message will appear and the n command cannot be found
n -h
When you forget the specific installation path of node, use the whereis or which command to query
whereis node
5. Configure the node file installation path
Step into the /usr/local/node/path:
mkdirnode_global
mkdirnode_cache
npmconfigsetprefix"node_global"
npmconfigsetcache"node_cache"
6. When you think npm is slow, you can install cnpm
npminstallcnpm-g--registry=
By the way, you can check whether the -g global installation is installed under the node_global file according to the previous settings.
Use cnpm globally as follows, and remember to configure a soft connection.
Note: npm does not need to be installed separately. When installing Node, npm will be installed together with it. Moreover, the npm provided with Node may not be the latest version. Finally, use the following command to update to the latest version.
#sudonpminstallnpm@latest-g
The difference between nvm and n is quite big, which is reflected in:
So how to choose the linux command? Different people have different opinions, but here are some general suggestions:
If you use Windows, you have no choice linux modify the user environment variable, use n, or change to a Mac. If you frequently switch node versions (for example, you often test the features of the latest version locally while maintaining code compatibility in the production environment), then from the perspective of global module compatibility, you can only use nvm. If you are a lightweight user who does not need to worry about compatibility issues and is more concerned about the experience of installing and using node, choose n.
If you want to askLinux modification of user environment variables, who did the poster finally choose? I will say, I went with the more popular one.
The above is the detailed content of Download the installation path introduction format of nodejsLinux version. For more information, please follow other related articles on the PHP Chinese website!