nvm: oh-my-zsh: NVM is not compatible with the npm config "prefix" option

Very annoying issue; every time I want to use node or NPM, I get this error and need to run a command to solve it.

nvm is not compatible with the npm config "prefix" option: currently set to "/Users/fabian/.nvm/versions/node/v0.12.7"
Run `nvm use --delete-prefix v0.12.7` to unset it.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 141
  • Comments: 335 (127 by maintainers)

Commits related to this issue

Most upvoted comments

Try config the $NVM_DIR reference again.

For example nvm use v7.10.0, and have the error: Run npm config delete prefix or nvm use --delete-prefix v7.10.0 --silent to unset it.

You need overwrite nvm prefix,

npm config set prefix $NVM_DIR/versions/node/v7.10.0

for future wanderers:

i had to rm /usr/local/bin/npm so that the one from within nvm would be used and not something i installed ages ago globally

The Fix

rm $(which npm) if and only if it was installed by a non-nvm node and is taking precedence over nvm’s node.

You can check this by doing the following:

nvm deactivate
ls -la $(which npm)

If it points to something outside of $NVM_DIR it may be causing problems.

The explanation

I ran into this today ONLY when starting tmux. I am using oh-my-zsh on a mac however I think the following may benefit anyone.

First, I uninstalled node from brew brew uninstall node Then I debugged a ton and found that the npm being used was a leftover from my brew node installation. npm was located at /usr/local/bin/npm but symlinked to /usr/local/lib/node_modules. Because of this, the default prefix was takining over and set to /usr/local.

So I performed the following to ensure brew’s node was gone:

sudo rm -rf  /usr/local/lib/node_modules
rm /usr/local/bin/npm
brew uninstall --force node
brew prune

No more errors YAY!

In hindsight, I believe all I really needed to do was either rm the npm symlink in /usr/local/bin and perhaps the npm install source at /usr/local/lib/node_modules/bin/npm (not sure of this path).

@rudeworks nvm is utterly unsupported on homebrew - please brew uninstall that, and install using the proper curl command in the readme, and see if you’re still having issues?

I’ve just had this problem, none of the “worked for me” solutions did work for me, but I managed another way… (apologies if someone has already suggested this, I only quickly scanned this huge thread)

Run nvm unload then which npm. This pointed me to a copy of npm in /usr/local/bin sym-linked to /usr/local/lib/node_modules/...

I ran rm -rf /usr/local/lib/node_modules /usr/local/bin/npm and the issue went away

For what it’s worth, I had to solve this by removing a few files and directories …

rm -rdf /usr/local/lib/node_modules
rm -rdf /usr/local/bin/npm

I believe, but don’t have any verifiable evidence of this, that these may have gotten installed by brew when I installed yarn and then had to use brew to force uninstall node.

change “export NVM_DIR=~/.nvm” to absolute path “export NVM_DIR=/Users/myname/.nvm” in .zshrc file worked for me.

FWIW, I am on MacOS (High Sierra 10.13.3) and I only get this error when using the integrated terminal of VS Code (Version 1.21.1). No error on iTerm. No error on Terminal.

The Problem:

The default setting of VS Code: "terminal.integrated.shellArgs.osx": ["-l"]

My Fix: (Note: This is just a quick band-aid fix)

  1. Set User Settings for this property to an empty array: "terminal.integrated.shellArgs.osx": []
  2. That fix might break the prompt of the terminal to the basic bash-[versionNumber]$
  3. To restore original prompt, add this to .bashrc or .bash_profile: export PS1='$(hostname -s):${PWD##*/} $(whoami)\$ '

I had the prefix error in node 4.2.x when using a symlinked dotfiles directory (I use dotbot). Since the .nvm directory was actually sym-linked to the nvm submodule location in my dotfiles path, the real path didn’t match the NVM_DIR. I was able to solve it by using the following NVM_DIR definition in my bashrc:

export NVM_DIR=$(readlink -f "$HOME/.nvm")

This way the NVM_DIR is set to the actual path wherever my dotfiles working directory is, which may be different on my various systems, although it is always linked to ~/.nvm for convenience.

I’m also getting this issue on Yosemite:

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/nvm/0.27.1/versions/node/v4.1.1"
Run `nvm use --delete-prefix v4.1.1 --silent` to unset it.

Once I run nvm use --delete-prefix v4.1.1 --silent it starts working normally, but I have to do it every time I open a new session.

for those try to remove nvm from brew it may not be enough to just brew uninstall nvm if you see npm prefix is still /usr/local, run this command sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*} (thanks Dominic Tancredi)

just nvm use node

I met the prefix issue and solved. Because my $HOME is symbolic link, so the prefix is out of expected, nvm_tree_contains_path "$NVM_DIR" "$NVM_NPM_PREFIX" check failed in nvm.sh use

export NVM_DIR=$(realpath "$HOME/.nvm")

it is solved

Just add a line before export NVM_DIR="$HOME/.nvm", like this:

# nvm
unset npm_config_prefix # Add this line
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

It works for me, but don’t know why.

This code fixed for me.

In my .zshrc

export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

I work on Debian Stretch with Bash, I solved this issue by modifying the ~/.bashrc config like this: Delete ~/.nvm and ~/.npm folders (not sure it is needed maybe just change the ~/.bashrc first): Install nvm according to the github page.

Then in ~.bashrc put (fix): export NVM_DIR=“${HOME}.nvm” [ -s “$NVM_DIR/nvm.sh” ] && . “$NVM_DIR/nvm.sh” # This loads nvm [ -s “$NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm

fix: I replaced: export NVM_DIR=“$HOME/.nvm” with: export NVM_DIR=“${HOME}.nvm” # the extra forward slash was the issue for me

then finish your installation like this: nvm install node nvm use node nvm alias default node

To know if you have the same issue as I had: in Bash do: echo $NVM_DIR # after nvm install and ~/.bashrc edited You have the same issue if you have similar output: /home/marc//.nvm/ # beware double forward slash

Using npm config delete prefix before loading nvm doesn’t change the output of npm config get prefix. How can I ensure the prefix is deleted before loading nvm?

for vscode (or any editor), i believe you’d need to find a way to configure it to use a login shell.

It’s worth noting that the default “user settings” of vscode include the -l flag (which makes it a login shell) in terminal.integrated.shellArgs.osx.

I tried setting it explicitly, but no dice:

"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.shellArgs.osx": ["-l"],

Any other ideas? This only happens in vscode for me.

  • macOS Mojave v10.14.1
  • nvm v0.33.11

Issue solved

Upgrading nvm to v0.34.0 has fixed the issue for me. 🎉

40 thumbs, hundreds of comments, switching Node versions is still misery.

Let me be clear, I’m not blaming nvm or their maintainers. Just pointing out that no one has really nailed this down. I feel like it would be nice if the Node org came up with an official cross-platform solution.

After trying all of the above, the only thing that seemed to work for me was removing /usr/local/bin/node, which I have no idea how it got there 😀 Must have been from some previous installation years ago.

I solve it use this in .bash_profile

export NVM_DIR="${HOME}/.nvm"
source /usr/local/opt/nvm/nvm.sh

you must ensure the nvm.sh excute after you define the export NVM_DIR="${HOME}/.nvm"

chinese

我在.bash_profile文件中嵌入了如下环境配置

export NVM_DIR="${HOME}/.nvm"
source /usr/local/opt/nvm/nvm.sh

出现这个问题的原因是因为 执行的脚本里面要使用声明的环境变量 NVM_DIR

brew uninstall --ignore-dependencies node solved it for me as I had an old version of node lying around.

@zhouytforever run nvm alias default node and you should be all set. If not, please file a new issue instead of adding onto this one 😃

Just in case it might help anyone. I was having this error show up every time I log in to my server and after doing

echo $HOME && echo $NVM_DIR
/home/user/
/home/user//.nvm

I realized I have an extra forward slash. I edited my .bashrc which had export NVM_DIR="/home/user//.nvm" and removed this extra /

I don’t see the warning anymore.

😀,I solve this problem by removing below code in my .zshrc

 export NVM_DIR="/Users/Huibean/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

I don’t realize these existed in my .zshrc while I add below to my .bash_profile after install nvm

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

obviously, the code in .zshrc rewrite the NVM_DIR, cause my $HOME is “/Users/huibean/” not “/Users/Huibean/”

Lots of people above have provided solutions to this including reinstall node, uninstall brew node, reinstall nvm etc.

But really the only essential step you need to do is to remove the wrong npm reference applied before your nvm script path settings.

Most of the time this is /usr/loca/bin/npm

Which means you just need to do rm /usr/loca/bin/npm and restart your terminal.

If this doesn’t solve the problem, you can run which npm before your nvm path setting script to find out what is it, and just remove it.

Thanks! @ljharb I used the curl command (curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash) to install version v0.34 but now that I’m running nvm --version, I’m still seeing v0.33.11

@ljharb ok, no problem. by the way, you said “can you file a new issue” in fact, you would like to say “can you open a new issue”

I met this issue as well, and resolved it by added the following lines to ~/.zshrc file.

export NVM_DIR="$HOME/.nvm"  
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm    
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
export PATH=$HOME/.nvm/versions/node/v12.16.3/bin:$PATH

图片

  • OS: Ubuntu 18.04
  • Terminal: on-my-zsh
  • NVM: 0.35.2

I solved this by removing the prefix= line from my .npmrc file.

It’s specifically mentioned in the Notes section of the README. I just missed it the first time I installed nvm.

NOTE: I’m not using oh-my-zsh, but I can’t be the only Terminal user who ended up here. 🤠

@bryansray Thanks! Yeah, brew install yarn also installs Node.js. To fix the problem I had to: brew uninstall node

Certainly using brew to install node has broken things for a lot of people; thanks for that suggestion.

This error occurred when my $HOME was a symlink. Replacing

export NVM_DIR="$HOME/.nvm"

with

export NVM_DIR="$(realpath $HOME)/.nvm"

worked for me.

Upgrading to the latest version of nvm fixed the issue for me (0.35.3). As a precaution, I removed the ~/.nvm directory and installed fresh versions of Node.js using the updated nvm.

See https://github.com/nvm-sh/nvm for instructions.

Hi, Like some of the others, I too was only experiencing this issue in vscode. I am on version 0.33.11. Afteer some tinkering around, I unchecked the Terminal > Integrated > Inherit Env option. Here is the corresponding setting in json: "terminal.integrated.inheritEnv": false This seemed to have fixed the issue for me.

Using npm config delete prefix before loading nvm doesn’t change the output of npm config get prefix. How can I ensure the prefix is deleted before loading nvm?

for vscode (or any editor), i believe you’d need to find a way to configure it to use a login shell.

It’s worth noting that the default “user settings” of vscode include the -l flag (which makes it a login shell) in terminal.integrated.shellArgs.osx.

I tried setting it explicitly, but no dice:

"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.shellArgs.osx": ["-l"],

Any other ideas? This only happens in vscode for me.

  • macOS Mojave v10.14.1
  • nvm v0.33.11

Issue solved

Upgrading nvm to v0.34.0 has fixed the issue for me. 🎉

upgrading had no effect for me. fwiw, my system was set via a template provided by my org. by default it put all the homes under /local so /home/bill was a symlink to /local/home/bill. this caused oh-my-zsh plugins and others to have an issue. (Perhaps it detected /home/bill/.nvm !== /local/home/bill/.nvm and assumed it was a prefix…??)

When I explicitly set export NVM_DIR=/local/home/bill/.nvm then everything worked fine, including the official and zsh-nvm plugins

HTH

https://github.com/creationix/nvm/issues/855#issuecomment-147127139

What if you try export NVM_DIR="/Users/isaac/.nvm"?

I’ve added $HOME info to nvm debug in c957989 to hopefully try to catch this sooner next time 😃

@ljharb This fixed it for me! Must be something to do with ~/ in zsh? 🤔

Hi everyone,

I had the same issue, but after I have read /usr/local/opt/nvm/README.md and made change in ~/.zshrs to

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

The message has been disapeared and everything looks working.

Have a nice day!

I am on a mac v10.13.2, i am using oh-my-zsh, i’ve install nvm using Homebrew.
For me this solution work very well: 1 - brew uninstall nvm 2 - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash it work on Terminal as well as iTerm, but the problem persist on VScode.

I was able to resolve this issue by exporting NPM_AUTH_TOKEN before the NVM setup in my .zshrc.

+export NPM_AUTH_TOKEN=xxxxx

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

-+export NPM_AUTH_TOKEN=xxxxx

I had this issue as well. Figured out that I had installed node via homebrew prior to installing nvm.

So the solution was: uninstall homebrew’s node, and the issue is fixed.

@abr4xas if you change that to export NVM_DIR="$HOME/.nvm" your problems will go away.

Hi guys, this is not a solution but just an quick work-around idea:

echo "nvm use --delete-prefix v6.3.1" >> ~/.bash_profile

at least you will be able to use node with every new terminal session 😃

Had this issue from operator error and corrected it.

This works for me ⬇️

if test "$(which brew)"; then

  NVM_INSTALL=$(brew --prefix nvm)

  if [ -d "$NVM_INSTALL" ]; then
    export NVM_DIR="$HOME/.nvm"
    . "$NVM_INSTALL/nvm.sh"
  fi
fi

⬆️

  • Installing with Homebrew 🇨🇦sorey🇨🇦
  • Using same script for Zsh and Bash
  • Not symlinking anything or anything fancy

#855 (comment)

What if you try export NVM_DIR="/Users/isaac/.nvm"? I’ve added $HOME info to nvm debug in c957989 to hopefully try to catch this sooner next time 😃

@ljharb This fixed it for me! Must be something to do with ~/ in zsh? 🤔

more can be said,this situation occur in vscode’s terminal

I met the prefix issue and solved. Because my $HOME is symbolic link, so the prefix is out of expected, nvm_tree_contains_path “$NVM_DIR” “$NVM_NPM_PREFIX” check failed in nvm.sh use

export NVM_DIR=$(realpath “$HOME/.nvm”) it is solved

Same here.

@dan-j’s solution solved my problem

Just a little update here as it may help some: The wrong npm (/usr/local/lib/node_modules/npm/bin/npm) was symlinked to /usr/local/bin/npm I removed the symlink, so now my npm is the nvm one ($NVM_DIR/versions/node/<version>/bin/npm) And no prefix anymore 😃

What if you try export NVM_DIR="/Users/isaac/.nvm"?

I’ve added $HOME info to nvm debug in c957989fa96ca28994e130cc3682eee87eb40a9f to hopefully try to catch this sooner next time 😃

@ljharb I have tried nvm with pure zsh, with oh-my-zsh and with zgen all of them have this bug

Hello, On my side, all of these solutions did not solve my problem.
But I finally find it, my $HOME value was /Users/alexandre while the real path was /Users/Alexandre. So I first hardcoded the NVM_DIR var with the matching case, and as it was ok I finally renamed by home folder all in lower case to avoid other similar problems.
Hope it helps too…

uninstall node version(broken), and reinstall node version. here is a example: nvm uninstall v4.7.3 && nvm install v4.7.3

No, “can you file” is correct. “file” and “open” are a synonym when applied to issues.

thanks @ljharb the install instruction clearly mentions that brew install is not supported. Do not get this with a curl installation as mentioned.

@ljharb this issue is now gone on Bash for Windows using Insider Preview build 15051

I had a case issue on (10.12|zsh) although $HOME returned /Users/name, when I checked the /Users it was still in /Users/Name - renaming the folder to lowercase fixed the issue.

guys I had the same problem. and I managed to fix it by just adding export NPM_TOKEN="" before nvm loading in oh-my-zsh and it fixed.

export NPM_TOKEN=""
export NVM_DIR="/Users/pasinduperera/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

Note when i tried npm config get prefix it failed too as it is used in the nvm. As i dig into npm code i found that they tries to aggregate the env variables global variables into one variable at v6.9.4/lib/node_modules/npm/lib/config/core.js this might be silly

I think i might face issues when i try to npm login.

For me, it works to re-install node with nvm.

Assume that the version is 6.9.1,

nvm uninstall 6.9.1 nvm install 6.9.1

With above command, the warning message is vanished!

Been having this issue for weeks now, for me the fix was:

export NVM_DIR=$(readlink "$HOME/.nvm")
source ~/.nvm/nvm.sh

where

$ readlink "$HOME/.nvm"
/Volumes/WS/apps/nvm

on OSX 10.11 ans zsh (omzsh)

is there anything in ~/.npmrc that references that PEM file?

@davidpronk your problem is that you have npm installed in ~/.node, and you have that set as your prefix - check ~/.npmrc, and the PREFIX or NPM_CONFIG_PREFIX environment variables - these must be unset for nvm to work.

@bsorem-sugarcrm please do not ever install nvm with homebrew. It’s completely unsupported. Install using the curl command in the readme, please.

Sorry, I am using oh-my-zsh yes. And just to confirm, the first bad commit is 1458de7

One thing I am doing though, is symlinking ~/.nvm to ~/Development/nvm (i.e. ~/.nvm is the symlink). So npm config get prefix always gives me a result that is outside of ~/.nvm.

Getting rid of the symlink, and moving the nvm dir to a single location and sourcing it from there only, also gets rid of the error.

If you try to set the “prefix” that will break nvm.

As a temporary workaround, you can do nvm use --delete-prefix v0.12.7, but this is a bug specifically with omz. I’ll have to figure out which option to unset when doing the comparison.

This issue was resolved in v0.37.0 with #2317

@Xananax would you mind filing that as a new issue, with the full issue template filled out?

Btw, just noticed that Fedora Silverblue also uses symlinks in home paths:

$ ls -lad /home
lrwxrwxrwx. 3 root root 8 Feb 22  2020 /home -> var/home

UPDATE: However, it doesn’t seem to be triggering the prefix error message (like e.g. on FreeBSD), as Fedora seems to set $HOME to the physical path (so without a symlink in it).

how to fix:

  • edit ~/.zprofile
#######################################################
#                 for nodejs nvm:
#######################################################
# fix:
nvm use --delete-prefix default

  • then, source ~/.zprofile
  • it’s fix my zsh .

if that doesn’t work

  • you can do:

brew uninstall --force node

  • then, source ~/.zprofile again.

Let’s file a separate issue to discuss that then; that sounds more complicated.

@ljharb thanks, that worked!

@donaral try removing your system node

@ceccode i suspect that’s a different problem, related to the files tmux is sourcing. Can you file a separate issue?

I am on a mac v10.13.16, i am using oh-my-zsh. It work on Terminal as well as iTerm, but the problem persist with Tmux

That issue doesn’t apply when using nvm, so no prefix is needed. Either way, regardless of npm’s advice, setting the prefix isn’t a good idea.

@ljharb I set prefix to avoid permission issue related to this post

I am using dotfiles , so yes. But I set the NVM_DIR to the actual path.

That’s the root problem I guess. I will try reinstalling without dotfiles symlink.

Thanks

@reallistic save my day!

The difference is I installed yarn by brew, so I need to add one more option --ignore-dependencies to successfully remove node from brew.

brew uninstall --ignore-dependencies --force node

Yarn could not get any node for now, nvm use [node-version] will solve this problem.

Everything work as expected.

My .zshrc looked liked this:

source $ZSH/oh-my-zsh.sh
... 
export NODE_VERSION="$(nvm current)"  # "v9.2.0"
export NODE_PATH="$HOME/.nvm/versions/node/$NODE_VERSION"                                                                                                                   
export PATH="$PATH:$NODE_PATH/bin"
...
source /usr/share/nvm/init-nvm.sh

and i got the same problem. It got fixed when i called the init-nvm.sh earlier. Not at the end but near at the beginning.

source $ZSH/oh-my-zsh.sh
source /usr/share/nvm/init-nvm.sh
... 
export NODE_VERSION="$(nvm current)"  # "v9.2.0"
export NODE_PATH="$HOME/.nvm/versions/node/$NODE_VERSION"                                                                                                                   
export PATH="$PATH:$NODE_PATH/bin"
...

@ljharb thank you a lot, you save my day!

@ljharb thanks. Looked it up on the MS side and for Bash for Windows this is a known issue https://github.com/Microsoft/BashOnWindows/issues/1683. I’m not seeing it on macOS.

@luixaviles in your case there’s no issue; it’s literally working exactly as designed 😃 you had a “prefix” setting in ~/.npmrc, and the --delete-prefix command removed it. 🎉

uninstalling 6.9.1 and reinstalling doesnt work for me. i am on ubuntu 16.04.01.

I am using oh-my-zsh, It seems it doesnt want to delete the prefix… hmm.

nvm is not compatible with the npm config "prefix" option: currently set to "/opt/vApps1/home/mhdevita/.nvm/versions/node/v6.9.1"
Run `nvm use --delete-prefix v6.9.1 --silent` to unset it.
mhdevita@phxlv-bup03 ~
  % nvm use --delete-prefix v6.9.1 --silent                                                                       !1381

mhdevita@phxlv-bup03 ~
  % nvm debug                                                                                                     !1382
nvm --version: v0.32.1
$SHELL: /bin/zsh
$HOME: /opt/home/mhdevita
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v6.9.1
which node: $NVM_DIR/versions/node/v6.9.1/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v6.9.1/bin/npm
npm config get prefix: /opt/vApps1/home/mhdevita/.nvm/versions/node/v6.9.1
npm root -g: /opt/vApps1/home/mhdevita/.nvm/versions/node/v6.9.1/lib/node_modules

mhdevita@phxlv-bup03 ~
  % npm config get prefix                                                                                         !1385
zsh: correct 'config' to '.config' [nyae]? n
/opt/vApps1/home/mhdevita

mhdevita@phxlv-bup03 ~
  % npm config delete prefix                                                                                      !1387
zsh: correct 'config' to '.config' [nyae]? n

mhdevita@phxlv-bup03 ~
  % npm config get prefix                                                                                         !1388
zsh: correct 'config' to '.config' [nyae]? n
/opt/vApps1/home/mhdevita/.nvm/versions/node/v6.9.1

Here’s the Google Translate version of @myoneray’s previous comment in English:

I have also been troubled by this mistake before finding a solution. Re-installation can be.

  • Unload node and nvm
  • Uninstall zsh
  • Install nvm
  • Install node
  • Install zsh

Can it!

You can refer to the first few steps here. My blog

@ljharb - No. My cenario was this:

1 - installed osx and created ‘alexandre’ user; 2 - installed nvm; 3 - changed ‘alexandre’ home and settings to ‘Alexandre’; 4 - the annoing bug started and --delete-prefix only fixes temporary (session); 5 - changed NVM_DIR from ‘alexandre’ to ‘Alexandre’ on .zshrc; 6 - run one time with --delete-prefix and this totally fixed the bug for me;

@Daniel-ltw See my comment above, https://github.com/creationix/nvm/issues/855#issuecomment-186935754, and my corresponding mini-containers/base comment, https://github.com/mini-containers/base/issues/5#issuecomment-186934231.

In short, on Alpine, the musl standard C library is missing some symbols, causing the dynamic linker to fail, resulting in the “No such file or directory” report for a binary that very clearly exists. So it seems nvm currently isn’t compatible with Alpine. (Unless someone with deeper and knowledge and experience than me can report otherwise.)

ugh - that fixed it. that was embarassing 😞 Thanks a lot for looking into this.

I’m wondering if perhaps it’s related to your home dir being Ying and NVM_DIR being ying? Do you have a case-insensitive filesystem?

I have the same issue, npm config get prefix =>/data1/home/oswap/.nvm/versions/node/v5.6.0

when i use following line command: npm config set prefix /home/oswap/.nvm/versions/node/v5.6.0

resolved!

I ran into the same issue just because I had NVM_DIR="/opt/nvm/" instead of NVM_DIR="/opt/nvm" into my .zshrc .

same here, on OSX 10.10.4 (Yosemite)

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v0.12.2 --silent` to unset it.

⚡ nvm debug
$SHELL: /bin/zsh
$NVM_DIR: $HOME/.nvm
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: /usr/local/bin/npm
npm config get prefix: env: node: No such file or directory
npm root -g: env: node: No such file or directory

⚡ nvm use --delete-prefix v0.12.2 --silent

⚡ nvm debug
$SHELL: /bin/zsh
$NVM_DIR: $HOME/.nvm
nvm current: v0.12.2
which node: $NVM_DIR/versions/node/v0.12.2/bin/node
which iojs: iojs not found
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules

If I can help in anyway, tell me

@ljharb here is the output for nvm debug:

$SHELL: /bin/bash
$NVM_DIR: '$HOME/.nvm/'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node: 
which iojs: 
which npm: /usr/local/bin/npm
npm config get prefix: env: node: No such file or directory
npm root -g: env: node: No such file or directory

Thanks! so, clearly you don’t have an npm prefix set.

Are you by chance using oh-my-zsh? That tends to set tons of opts that nvm has to manually account for.

Thanks for the report! What does nvm deactivate ; nvm debug ; echo $PREFIX ; echo $NPM_CONFIG_PREFIX print out?