Home >Web Front-end >JS Tutorial >Example tutorial for installing nodejs and npm under linux
Download the npm installation package from the official website. The stable version is on the left and the latest version is on the right.
Extract the compressed package to the /opt (general software is placed in this directory) directory. You can see that there are two executable files node and npm in the bin directory. Create a link to the file in /usr/local/bin
sudo ln -s /opt/node-v0.12.10-linux-x86/bin/node /usr/local/bin/node sudo ln -s /opt/node-v0.12.10-linux-x86/bin/npm /usr/local/bin/npm
and then use node -v, npm - vVerify whether it is successful
Modify the configuration file .bashrc. If you modify the .bashrc file under a specific user, it will only take effect for that user. If you want it to take effect for all users , can modify the global configuration file. For example, /etc/profile or /etc/bash.bashrc
Add the following code at the end of the configuration file:
alias cnpm="npm --registry= \--cache=$HOME/.npm/.cache/cnpm \--disturl=https://npm.taobao.org/dist \--userconfig=$HOME/.cnpmrc"
After modification, use source /etc/profile ( source and then modify the specific file) to make the configuration take effect.
Then you can use cnpm to install the plug-in
The above is the detailed content of Example tutorial for installing nodejs and npm under linux. For more information, please follow other related articles on the PHP Chinese website!