npm install -g throws EACCES: permission denied because npm tries to write global packages to system directories like /usr/lib/node_modules, where a normal user has no write access.
It looks like this:
npm error code EACCES
npm error syscall rename
npm error path /usr/lib/node_modules/npm/node_modules/env-paths
npm error errno -13
npm error Error: EACCES: permission denied
Don’t brute-force it with sudo — that just chowns a bunch of files to root and makes things worse. Move the global prefix into your home directory instead:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Then add its bin to your PATH in your shell config (~/.bashrc for bash, ~/.zshrc for zsh):
export PATH=~/.npm-global/bin:$PATH
Source it, and npm install -g works without sudo:
source ~/.bashrc
npm install -g @musistudio/claude-code-router