Jpom/script/install-node.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

2022-09-06 09:32:11 +08:00
#!/usr/bin/bash
2022-09-07 10:26:59 +08:00
#
# Copyright (c) 2019 Of Him Code Technology Studio
2024-02-29 14:10:24 +08:00
# Jpom is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
2022-09-07 10:26:59 +08:00
#
2022-09-06 09:32:11 +08:00
# shellcheck disable=SC2016,SC2119,SC2155,SC2206,SC2207,SC2254
2024-01-08 18:42:21 +08:00
node_version=18.19.0
2022-09-06 09:32:11 +08:00
ARCH="$(dpkg --print-architecture)"
case "${ARCH}" in
aarch64 | arm64)
BINARY_ARCH='arm64'
;;
amd64 | x86_64)
BINARY_ARCH='x64'
;;
*)
echo "Unsupported arch: ${ARCH}"
exit 1
;;
esac
curl -LfsSo /opt/node-v${node_version}-linux-${BINARY_ARCH}.tar.gz https://npmmirror.com/mirrors/node/v${node_version}/node-v${node_version}-linux-${BINARY_ARCH}.tar.gz
tar -zxvf /opt/node-v${node_version}-linux-${BINARY_ARCH}.tar.gz -C /opt/
cat >"/etc/profile" <<EOL
# node js
export NODE_HOME="/opt/node-v${node_version}-linux-${BINARY_ARCH}/"
export PATH=$PATH:$NODE_HOME/bin
EOL
source /etc/profile
node -v