← 전체로 돌아가기
스킬 shell

Mac npm 권한 문제 해결

macOS npm 권한 문제, sudo 없이 해결하기

npmmacospermissioneaccesenvironment-variable

macOS에서 npm 글로벌 패키지 설치 시 EACCES 에러가 발생하면 sudo 없이 해결해보자. npm의 기본 설치 경로를 사용자 홈 디렉토리로 변경하는 방법이야.

  • 글로벌 디렉토리 생성: bash mkdir ~/.npm-global

  • npm 경로 설정: bash npm config set prefix '~/.npm-global'

  • PATH 환경 변수 추가: .zshrc (또는 .bash_profile) 파일에 다음을 추가해. bash echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc

  • 쉘 적용: bash source ~/.zshrc

  • 테스트: 이제 sudo 없이 글로벌 패키지를 설치하면 된다. bash npm install -g <package-name> EACCES 에러는 안녕!

여기서 배울 것

  1. npm EACCES 에러를 sudo 없이 해결하는 방법
  2. npm 글로벌 패키지 설치 경로 변경하기
  3. PATH 환경 변수 설정 및 쉘에 적용하기
  4. 사용자 홈 디렉토리에서 npm 패키지 관리하기
원본 파일 보기 (.claude/skills/tn-mac-npm-permission-fix/SKILL.md)
---
name: Mac npm 권한 문제 해결
description: Use when the user encounters permission errors with npm on macOS, such as 'EACCES' errors when installing global packages, and needs a solution to fix npm permissions without using `sudo`.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/mac 권한 문제 해결법 62d4de43c2734d0ca5e425bcdf158407.md
---

# mac 권한 문제 해결법

[https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo/16151707#16151707](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo/16151707#16151707)

![Screen Shot 2023-02-28 at 7.01.00 PM.png](mac%20%EA%B6%8C%ED%95%9C%20%EB%AC%B8%EC%A0%9C%20%ED%95%B4%EA%B2%B0%EB%B2%95/Screen_Shot_2023-02-28_at_7.01.00_PM.png)