centos安装的nodejs更新npm

  |  

npm 官网 :https://docs.npmjs.com/getting-started/installing-node
安装 nodejs [官方介绍请看这里:https://github.com/nodesource/distributions]

  1. 安装 nodejs:
    下载包 我这里下载是版本10的包
    curl -sL https://rpm.nodesource.com/setup_10.x | bash -
    安装
    yum install -y nodejs
    查看node版本
    node -v
  1. 更新 npm
    npm install npm@latest -g
    查看npm版本
    npm -v

如果你发现nodejs和你的程序不对,我就碰上了,我刚开始下载了11的包,版本太高,程序报错,后来改成10。
1.卸载npm:sudo npm uninstall npm -g
2.卸载nodejs包:yum remove nodejs
3. cd 到yum源配置文件夹:cd /etc/yum.repo.d ,删除以 node 开头的源
4. 清除 yum 缓存 yum clean all

sudo yum install -y git

文章目录