美文网首页
Ubuntu 安装/更新 node和npm

Ubuntu 安装/更新 node和npm

作者: 夜空最亮的9星 | 来源:发表于2022-07-01 10:01 被阅读0次

    方法是针对系统中已存在nodejs,由于版本低需要升级可以进行如下操作,依次执行即可完成node升级:

    sudo npm install n -g
    sudo n stable
    
    
    root@master-node:~# n stable
      installing : node-v16.15.1
           mkdir : /usr/local/n/versions/node/16.15.1
           fetch : https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz
         copying : node/16.15.1
       installed : v16.15.1 (with npm 8.11.0)
    
    Note: the node command changed location and the old location may be remembered in your current shell.
             old : /usr/bin/node
             new : /usr/local/bin/node
    If "node --version" shows the old version then start a new shell, or reset the location hash with:
    hash -r  (for bash, zsh, ash, dash, and ksh)
    rehash   (for csh and tcsh)
    
    
    root@master-node:~# node -v
    v8.10.0
    root@master-node:~# hash -r bash
    root@master-node:~# node -v
    v16.15.1
    root@master-node:~#  npm install -g npm@8.13.2
    

    Using Ubuntu

    curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
    sudo apt-get install -y nodejs
    sudo npm install -g npm
    

    相关文章

      网友评论

          本文标题:Ubuntu 安装/更新 node和npm

          本文链接:https://www.haomeiwen.com/subject/baccbrtx.html