[TIL] zsh: command not found npm

Seungrok Yoon (Lethe)·2023년 11월 2일
0

[TIL] 성장 한 스푼

목록 보기
42/49

문제상황

맥에서 oh-my-zsh로 쉘을 변경 후에 nvm, npm을 쉘에서 찾지 못한다.

해결책

https://github.com/nvm-sh/nvm#installing-and-updating

nvm 공식문서의 설치 부분에 보면, 아래와 같은 설명이 있다. 핵심은 install script를 실행하고 나면, nvm 레포지토리 폴더를 ~/.nvm경로에 클론을 하고, 아래 코드 스니펫을 쉘의 profile file에 추가한다는 이야기다.

Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

그렇지만, 내 기기에 oh-my-zsh를 설치하고 나서 .zshrc 파일을 찾아서 들어가보았을 때는 위 스크립트가 존재하지 않았다.

그래서 저 코드 스니펫을 복사하여 추가해주었더니 제대로 nvm 패키지 위치를 찾아서 node도 제대로 동작하고, npm도 동작한다.

끝!

profile
안녕하세요 개발자 윤승록입니다. 내 성장을 가시적으로 기록하기 위해 블로그를 운영중입니다.

0개의 댓글