본문 바로가기

Operating Systems/Linux

[ Linux ] Nexus NPM 저장소 관리

[ 설정 ] 아이콘 ⇨ [ Repositories ] ⇨ [ Create repository ]
npm (hosted) 클릭
NPM 저장소 명 입력 ⇨ [ Create repository ]
[ Browse ] 아이콘 ⇨ Browse ⇨ NPM 저장소 명 오른쪽 [ copy ] 클릭
NPM 저장소 명 복사

# NPM 패키지 업로드

# 패키지 업로드용 임시 폴더 생성
mkdir -p /app/tmp/npm

chmod o+w /app/tmp/npm

# npm 설치 유저 생성
adduser nexus

su nexus

cd /app/tmp/npm

# NVM 설치 1
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

# NVM 설치 2
cat <<'NVM_SETTING' > /home/nexus/.bash_profile
# nvm 환경변수 설정 1
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"

# nvm 환경변수 설정 2
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
NVM_SETTING

source /home/nexus/.bash_profile

# node 설치
nvm install 14.21.3

NEXUS_URL="http://localhost:8881"
REPOSITORY="npm-hosted"

# Nexus 인증 정보
USERNAME="admin"
PASSWORD="P@ssw0rd!"

# npm 패키지 다운로드
npm pack typescript

# 다운로드된 패키지 파일명 추출
PACKAGE_FILE=$(ls typescript-*.tgz)

# npm 패키지 업로드
curl -u $USERNAME:$PASSWORD -X POST "$NEXUS_URL/service/rest/v1/components?repository=$REPOSITORY" -F "npm.asset=@$PACKAGE_FILE"

typescript 업로드 확인

# 사내 저장소 이용 NPM INSTALL
npm init -y

cat <<NPM_SETTING > /app/tmp/npm/.npmrc
registry=http://localhost:8881/repository/npm-hosted/
NPM_SETTING

npm install typescript

'Operating Systems > Linux' 카테고리의 다른 글

[ Linux ] 자주 사용하는 리눅스 명령어  (1) 2024.10.16
[ Linux ] Rocket.Chat 설치  (0) 2024.05.24
[ Linux ] OpenSSL 설치  (0) 2024.05.22
[ Linux ] MongoDB 설치  (0) 2024.05.22
[ Linux ] PIP 설치  (0) 2024.04.05