Notes
1.0.0
1.0.0
  • Introduction
  • Commands
    • cd
    • df
    • du
    • fc-cahe
    • ifconfig
    • ip
    • ls
    • lsb_release
    • mkdir
    • mksquashfs
    • mount
    • ping
    • pwd
    • rm
    • sar
    • sudo
  • Linux C
    • Preprocessor
    • Keywords
    • Kernel
      • Ftrace
      • Watchdog
  • Python
    • general
      • Decorator
      • Generator
      • Iterator
      • Lambda
    • Download
    • NIC
  • Network
    • Protocol
      • Link layer
      • IP
      • ARP
      • ICMP
    • Proxy
      • Cntlm
      • Proxychains4
      • ShadowSocks
    • Tools
      • iperf
      • tc
      • Wireshark
    • Apps
      • samba
      • tftp
  • Software
    • Atom
    • Chrome
    • Docker
    • Git
    • Gitbook
    • Hexo
    • Nodejs
    • Teraterm
    • Tex
    • Tmux
    • VIM
    • VSCode
  • Database
    • MongoDB
  • Web
    • CSS
    • LNMP
  • Tools
    • common
    • programming
  • Ubuntu
    • Add user
    • AWS EC2
    • FAQ
    • Installer
    • Shell
    • Shell scripts
    • Themes
    • VPS
  • Windows
    • PowerShell
    • CMD
    • FAQ
  • Aphorisms
  • Book List
  • Favorites
  • Appendix
    • ASCII
    • GSM
Powered by GitBook
On this page
  • 安装 Node.js
  • 源码安装
  • apt-get 安装
  • 官网下载安装
  • npm换源
  • 临时使用
  • 永久使用

Was this helpful?

  1. Software

Nodejs

安装 Node.js

源码安装

下载源码(300M左右)

sudo git clone https://github.com/nodejs/node.git

修改目录权限

sudo chmod -R 755 node

创建并编译文件

cd node
sudo ./configure
sudo make   # 耗时较长
sudo make install

apt-get 安装

sudo apt-get install nodejs
sudo apt-get install -y build-essential
sudo apt-get install npm
sudo npm install n -g   # 安装用于更新管理nodejs的工具,该项可选
sudo n stable   # 获取最新稳定版的nodejs

官网下载安装

  • 先到官网下载稳定版的nodejs,一般是tar.xz格式;

  • 然后解压至本地目录(如:~/Programs/)

  • 执行以下指令,若成功显示版本好,说明已经编译好,可以直接使用

cd node-v6.11.0-linux-x64
./node -v
  • 接下来配置环境变量,使其变为全局可用

ln -s /home/litreily/Programs/node-v6.11.0-linux-x64/bin/node /usr/local/bin/node
ln -s /home/litreily/Programs/node-v6.11.0-linux-x64/bin/npm /usr/local/bin/npm

npm换源

临时使用

npm --registry https://registry.npm.taobao.org install express

永久使用

npm config set registry https://registry.npm.taobao.org
npm config get registry  # 验证源
PreviousHexoNextTeraterm

Last updated 5 years ago

Was this helpful?