Ubuntu/Centosインストールnodejsとnpm

1248 ワード

Ubunt
  • udate
  •  sudo apt-get  update    
    
  • install nodejs
  • sudo apt-get  install  nodejs
    
    using node-v to check whether install success fully or not.
  • install npm
  • sudo apt-get  install  npm
    
    using npm-v to check.
    if you not excute 1.command,you will get this error when you install npm.(just run ap-get udate to solive it.)
    Do you want to continue? [Y/n] y
    Err:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main i386 libssl-dev i386 1.0.2g-1ubuntu4.8
      404  Not Found
    Err:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main i386 libssl-doc all 1.0.2g-1ubuntu4.8
      404  Not Found
    Unable to correct missing packages.
    E: Failed to fetch http://mirrors.cloud.aliyuncs.com/ubuntu/pool/main/o/openssl/libssl-dev_1.0.2g-1ubuntu4.8_i386.deb  404  Not Found
    
    E: Failed to fetch http://mirrors.cloud.aliyuncs.com/ubuntu/pool/main/o/openssl/libssl-doc_1.0.2g-1ubuntu4.8_all.deb  404  Not Found
    
    E: Aborting install.
    
    Centos
    yum -y install nodejs npm --enablerepo=epel
    
    Sometimes,you may find npm slow,try cnpm:
    npm install -g cnpm --registry=https://registry.npm.taobao.org