Home > Web Front-end > JS Tutorial > Example tutorial for installing nodejs and npm under linux

Example tutorial for installing nodejs and npm under linux

零下一度
Release: 2017-06-25 09:20:18
Original
1438 people have browsed it

1. Download the npm package

Download the npm installation package from the official website. The stable version is on the left and the latest version is on the right.

2. Unzip and create a link

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
Copy after login

and then use node -v, npm - vVerify whether it is successful

3. Use Taobao npm source

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"
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template