转载请注明出处: http://qiudeqing.com/nodejs/2017/04/29/basic.html

Ubuntu 16 安装nodejs

  1. 设置source

     # for Node.js v4
     curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
     # OR for Node.js v5
     curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
     # OR for Node.js v6
     curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
     # OR for Node.js v7
     curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
    
  2. 安装nodejs

     sudo apt-get install -y nodejs
    
  3. 更新, 如果需要更新版本. 先删掉当前版本再执行1,2操作

    sudo apt-get purge nodejs npm
    

参考资料