美文网首页
linux环境下node安装 - cnpm,pm2安装+构建软链

linux环境下node安装 - cnpm,pm2安装+构建软链

作者: 炒面Z | 来源:发表于2019-05-28 10:55 被阅读0次

    下载网址; http://nodejs.cn/download/

    image.png

    1.源码方式安装node

    下载node源码

    wget https://npm.taobao.org/mirrors/node/v10.15.3/node-v10.15.3.tar.gz

    解压 tar.gz文件

    tar -zxvf node-v10.15.3.tar.gz

    编译源码

    cd  node-v10.15.3
    ./configure
    make
    

    安装

    make install

    检查

    node -v

    npm -v

    如果不成功,再创建软链接

    2.二进制文件方式安装node

    下载二进制文件

    wget https://npm.taobao.org/mirrors/node/v10.15.3/node-v10.15.3-linux-x64.tar.xz

    解压 tar.xz文件

    tar xvJf node-v10.15.3-linux-x64.tar.xz

    创建软链接

    sudo ln -s /opt/software/node-v10.15.3-linux-x64/bin/node /usr/local/bin/
    sudo ln -s /opt/software/node-v10.15.3-linux-x64/bin/npm /usr/local/bin/

    3.node中安装cnpm

    安装命令

    npm install -g cnpm --registry=https://registry.npm.taobao.org
    

    创建软链接

    sudo ln -s /opt/software/node-v10.15.3-linux-x64/bin/cnpm /usr/local/bin/

    检查

    cnpm -v

    4. 安装 pm2 且构建软链接

    npm install pm2 -g
    
    root@xxx:/opt2/node/node-v14.15.0-linux-x64# npm install pm2 -g
    /opt2/node/node-v14.15.0-linux-x64/bin/pm2 -> /opt2/node/node-v14.15.0-linux-x64/lib/node_modules/pm2/bin/pm2
    /opt2/node/node-v14.15.0-linux-x64/bin/pm2-runtime -> /opt2/node/node-v14.15.0-linux-x64/lib/node_modules/pm2/bin/pm2-runtime
    /opt2/node/node-v14.15.0-linux-x64/bin/pm2-docker -> /opt2/node/node-v14.15.0-linux-x64/lib/node_modules/pm2/bin/pm2-docker
    /opt2/node/node-v14.15.0-linux-x64/bin/pm2-dev -> /opt2/node/node-v14.15.0-linux-x64/lib/node_modules/pm2/bin/pm2-dev
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    
    + pm2@4.5.0
    updated 1 package in 18.062s
    
    
    ## 软链接
    ln -s /opt2/node/node-v14.15.0-linux-x64/lib/node_modules/pm2/bin/pm2  /usr/local/bin
    
    ### 测试
    pm2 -v
    

    相关文章

      网友评论

          本文标题:linux环境下node安装 - cnpm,pm2安装+构建软链

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