User-writable npm prefix and nvm are incompatible

Resolved 💬 10 comments Opened Mar 6, 2025 by peterkaminski Closed Nov 30, 2025

MacBook Pro, M1 Max, Sonoma 14.7
zsh 5.9 (x86_64-apple-darwin23.0)
node v20.18.1 (npm v10.8.2)

To enable auto-updating, the current advice is to create a user-writable npm prefix:

https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/troubleshooting#recommended-solution-create-a-user-writable-npm-prefix

However, this conflicts with nvm, resulting in this error:

Your user’s .npmrc file (${HOME}/.npmrc) has a globalconfig and/or a prefix setting, which are incompatible with nvm. Run nvm use --delete-prefix v20.18.1 --silent to unset it.

I use nvm to lock the Node version for the project in which I use Claude Code, so I'm directly caught between the npm prefix and nvm conflict.

I asked Claude 3.7 for options, and got these:

https://claude.ai/chat/c23fc52a-c774-4de9-a627-68555f115aa4

I'm not sure any of them are great, so I'm not including them in this issue.

My workaround: I will disable auto-update, and continue to manually update.

However, I think it's inappropriate to recommend a user-writable npm prefix without documenting that it will conflict with nvm, and explaining the conflict and suggested workarounds. So, I recommend one of the following:

  • don't recommend a user-writable npm prefix (perhaps necessitating removal of auto-update)
  • document the conflict between user-writable npm prefix and nvm, and suggest a path forward
  • implement some reasonable way to make user-writable npm prefix and nvm work together

I think #263 may be pertinent; I apologize for the interlink to that issue if it's ultimately not relevant.

Thanks for Claude Code in general, it's awesome.

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗