首頁 運維 linux運維 如何在linux中安裝node

如何在linux中安裝node

May 12, 2023 pm 04:34 PM
linux node

在linux中安装node的方法:1、下载“node-v16.18.0-linux-x64.tar.xz”并将其放到linux服务器上;2、在linux上解压“node-v16.18.0-linux-x64.tar.xz”;3、配置全局路径PATH在“/etc/profile”文件中;4、刷新“source /etc/profile”;5、在bin文件中进行权限分配即可。

linux 服务器的node 安装

1.先下载 node 当然下载的是符合linux 系统的 我当时下载的是 node-v16.18.0-linux-x64.tar.xz

2. 把 node-v16.18.0-linux-x64.tar.xz 放到linux 服务器上 我当时是用ftq 放到了 /usr/local文件夹下新建了一个 node 文件

3.解压 node-v16.18.0-linux-x64.tar.xz 必须在linux 服务器上解压。在window 中解压再放上去使用npm 会报错 解压代码 tar -xJvf node-v16.18.0-linux-x64.tar.xz

4.配置 全局路劲PATH 在 /etc/profile 文件进行如下设置 注释:(主要看pathmunge 函数的使用不会的可以百度查一下linux 函数使用)把node文件里面bin 路劲添加到全局路径

pathmunge /usr/local/linuxNode/node-v16.18.0-linux-x64/bin after

# /etc/profile
 
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
 
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
#pathmunge 是Linux 函数  
pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}
 
 
if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`/usr/bin/id -u`
        UID=`/usr/bin/id -ru`
    fi
    USER="`/usr/bin/id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi
 
# Path manipulation 
#$EUID 是全局变量 判断用户是否具有权限
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi
 
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi
 
#使用 pathmunge 函数 
pathmunge /usr/local/linuxNode/node-v16.18.0-linux-x64/bin after
 
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
 
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi
 
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then 
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done
 
unset i
unset -f pathmunge
登入後複製

5.进行 刷新 source /etc/profile

6.进入到我们按钮的node 文件的bin 文件 进行权限分配。chmod +x node 或者 chmod +x node

以上是如何在linux中安裝node的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

Android TV Box 獲得非官方 Ubuntu 24.04 升級 Android TV Box 獲得非官方 Ubuntu 24.04 升級 Sep 05, 2024 am 06:33 AM

Android TV Box 獲得非官方 Ubuntu 24.04 升級

deepseek網頁版入口 deepseek官網入口 deepseek網頁版入口 deepseek官網入口 Feb 19, 2025 pm 04:54 PM

deepseek網頁版入口 deepseek官網入口

Pi Node教學:什麼是Pi節點?如何安裝和設定Pi Node? Pi Node教學:什麼是Pi節點?如何安裝和設定Pi Node? Mar 05, 2025 pm 05:57 PM

Pi Node教學:什麼是Pi節點?如何安裝和設定Pi Node?

deepseek怎麼安裝 deepseek怎麼安裝 Feb 19, 2025 pm 05:48 PM

deepseek怎麼安裝

BitPie比特派錢包app下載位址 BitPie比特派錢包app下載位址 Sep 10, 2024 pm 12:10 PM

BitPie比特派錢包app下載位址

BITGet官方網站安裝(2025新手指南) BITGet官方網站安裝(2025新手指南) Feb 21, 2025 pm 08:42 PM

BITGet官方網站安裝(2025新手指南)

詳解:Shell腳本變數判斷參數指令 詳解:Shell腳本變數判斷參數指令 Sep 02, 2024 pm 03:25 PM

詳解:Shell腳本變數判斷參數指令

Zabbix 3.4 原始碼編譯安裝 Zabbix 3.4 原始碼編譯安裝 Sep 04, 2024 am 07:32 AM

Zabbix 3.4 原始碼編譯安裝

See all articles