CentOS 安装、配置 nodejs(及 npm)

2022-02-28  本文已影响0人  hemiao3000

最简单的方案是通过 yum 安装 nodejs ,不过 yum 源中的版本较老<small>(10.24.0)</small>,当前(2021-04-01)最新的长期支持版是 14.16.0 。因此,如果你想安装最新版本的 nodejs,那么就不能从原始的 yum 源安装。

  1. 删除已安装的 nodejs

    yum remove -y pure nodejs
    
  2. 添加 node.js Yum 源

    curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
    
  3. 安装 nodejs

    yum install -y nodejs
    
  4. 验证

    node -v
    
    npm -v
    
  5. 设置 npm 的淘宝源,并验证

    npm config set registry https://registry.npm.taobao.org/
    
    npm info underscore
    
上一篇 下一篇

猜你喜欢

热点阅读