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.
Thanks for the report! What does nvm deactivate ; nvm debug ; echo $PREFIX ; echo $NPM_CONFIG_PREFIX print out?
Could not find /Users/Fabian/.nvm/*/bin in $PATH
Could not find /Users/Fabian/.nvm/*/share/man in $MANPATH
$SHELL: /bin/zsh
$NVM_DIR: /Users/Fabian/.nvm
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:74: command not found: npm
npm root -g: nvm:74: command not found: npm
and the env vars?
PATH=.:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/local/heroku/bin:/usr/local/mysql/bin:/usr/local/git/bin:/usr/local/mongodb/bin:/usr/bin:/usr/sbin:/usr/local/lib/AIRSDK:/usr/local/lib/AIRSDK/bin:/Users/fabian:/Users/fabian/bin:/Users/fabian/.bin:/Users/fabian/.phpdoc/bin:/Users/fabian/pear/bin:/Users/fabian/.composer/vendor/bin:/Users/fabian/android.ndk:/Users/fabian/android.sdk/r24.3.4:/Users/fabian/android.sdk/r24.3.4/tools:/Volumes/Hyper/Development/Go/bin:/Library/Java/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
TMPDIR=/var/folders/mp/hd4fy3n15z17_g9s4j11y8gm0000gn/T/
LOGNAME=fabian
XPC_FLAGS=0x0
HOME=/Users/fabian
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.WrQOEzC6ut/Render
TERM=xterm-256color
COLORFGBG=7;0
USER=fabian
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.FEGVlgCDcM/Listeners
ITERM_PROFILE=Default
TERM_PROGRAM=iTerm.app
XPC_SERVICE_NAME=0
SHELL=/bin/zsh
ITERM_SESSION_ID=w0t0p0
PWD=/Users/fabian
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
LC_CTYPE=UTF-8
SHLVL=1
OLDPWD=/Users/fabian
ZSH=/Users/fabian/.oh-my-zsh
LANG=en_US.UTF-8
GOPATH=/Volumes/Hyper/Development/Go
NODE_PATH=/usr/local/bin/node
NODE_HOME=/usr/local/lib/node
JAVA_HOME=/Library/Java/Home
ANDROID_SDK=/Users/fabian/android.sdk/r24.3.4
ANDROID_NDK=/Users/fabian/android.ndk
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
LS_COLORS=no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:
NVM_DIR=/Users/Fabian/.nvm
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
MANPATH=/usr/share/man:/usr/local/share/man:/usr/local/mysql/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man
NVM_PATH=/Users/Fabian/.nvm/versions/node/v0.12.7/lib/node
NVM_BIN=/Users/Fabian/.nvm/versions/node/v0.12.7/bin
_=/usr/bin/printenv
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.
Yeah, I am.. I could manually set it, I assume? How do I go about that?
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.
Okay, let me know if I can help with anything!
Could you provide the output of setopt as well? From there I should be able to try to debug it.
alwaystoend
autocd
autopushd
cdablevars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
nonomatch
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
Thanks! I'll take a look at this asap.
One more thing that could be interesting: this is a brand new installation of El Capitan; I didn't have this issue before on Mavericks (I also used oh my zsh on Mavericks)
Good to know - I don't have an El Capitan machine to test on just yet.
If you have anything else I should test for you, just let me know.
I definitely started noticing these issues after upgrading to El Capitan.
@mikepaggi you're also on zsh? are you using oh-my-zsh?
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.
@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 get the same error on Yosemite:
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/cristik/.nvm/v0.10.38"
Runnpm config delete prefixornvm use --delete-prefix v0.10.38 --silentto unset it.
and I installed using the curl command in readme.
@ckiss thanks - also on zsh?
FWIW I'm also getting this on Arch Linux also with zsh, with nvm installed both via curl and by manually cloning and sourcing nvm.sh in my .zshrc.
I hadn't updated nvm in a while, but I did just notice that the last 'good' tag (i.e. no error shown) was v0.26.1. I'll see if I can find the actual commit where this begins.
Thanks - I'm quite certain it's simply the commit where I added this check, which suggests that the check doesn't work properly in zsh. @jaromero, can you also confirm whether you are or are not using oh-my-zsh?
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.
@jaromero Sadly that is unsupported/broken at the moment - see #617. I think supporting that use case is a separate issue. Thank you for the data point though!
@ljharb I have tried nvm with pure zsh, with oh-my-zsh and with zgen
all of them have this bug
@foray1010 thank you for confirming! I'm still not seeing it locally on Yosemite, but I'll keep looking.
@ljharb I'm using osx bash terminal
@ckiss you may have a different issue. what's echo $NVM_DIR print out?
I installed it using curl and $NVM_DIR prints out /Users/cristik/.nvm/
@ckiss and nvm debug? If this doesn't help me figure it out, and you can use irc, i'm in #nvm on freenode as well - we can troubleshoot there.
@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 - that doesn't make any sense, it's exactly what I've got, and mine works. I assume your $HOME is on your primary disk (and you don't have any weird mount stuff going on)?
@ljharb nps. Yes, nothing unusual. Though if I run nvm use --delete-prefix v0.10.38 --silent and then i run nvm debug again I get completely different results:
$SHELL: /bin/bash
$NVM_DIR: '$HOME/.nvm/'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: system
which node: $NVM_DIR/v0.10.38/bin/node
which iojs:
which npm: $NVM_DIR/v0.10.38/bin/npm
npm config get prefix: $NVM_DIRv0.10.38
npm root -g: $NVM_DIRv0.10.38/lib/node_modules
ooh, a difference! my npm config get prefix is $NVM_DIR/v0.10.38 (note the slash) and my npm root -g is $NVM_DIR/v0.10.38/lib/node_modules. I'd bet that's the difference. Also, I note that nvm current prints out "system".
Could you gist your bashrc? Unless you have sed aliased in which case this is a red herring.
Thanks, no help there either.
Clearly there's something different about your system, and about those reporting above, that's making the prefix check fail. Basically, all it's doing is seeing if the npm config get prefix value is contained inside the $NVM_DIR value.
The omz and zsh users may have an option set I'm not accounting for, but that doesn't explain @ckiss' bash error. :-/ I'll keep looking into this for sure.
thanks @ljharb I'll keep looking myself and I'll let you know if I find something
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
@jobwat in your case, you have your npm prefix set to /usr/local - that's what nvm is incompatible with. You'll need to unset it to be able to use nvm - for you, the console output is actually correct :-)
Hi all, I had this issue and was able to resolve it. For what it is worth, I brew uninstalled nvm mostly because the version was not up to date with the latest and above it is recommended not to use brew. Then I copied my versions to the new install just to make it quicker and eliminate the need to install again along with node modules. I noticed that the one version I was getting the warning / error was using the brew npm and not the one from nvm version. The other nvm versions were fine. So, I nvm uninstalled and re-installed. That fixed it.
Very wild guess here, but this may have something to do with case (in)sensitivity. I have:
export NVM_DIR="${HOME}/.nvm"
in my zshrc, but:
echo $HOME
=> /Users/isaac
echo $NVM_DIR
=> /Users/Isaac/.nvm
and I saw this issue. Updating my zshrc to be export NVM_DIR="~/.nvm" has also not fixed this.
¯_(ツ)_/¯
@isaacseymour aha! that is a very helpful clue, thanks!
@foray1010 @ckiss what are all your echo $HOME && echo $NVM_DIR output?
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 :-)
Then it's totally fine. I'm still really confused as where the capital is creeping in - putting an echo $HOME or echo "${HOME}/lol" right above export NVM_DIR="${HOME}/.nvm" prints out the correct value. Computers.
Ok, I've actually just wasted loads of your time - this was a totally different issue. I somehow ended up with export NVM_DIR="/Users/Isaac/.nvm" in a gitignored file (so ag didn't find it...sigh). Removing that has everything fixed. The case change may have something to do with other peoples' issues though (I hope!)
@isaacseymour Awesome, thanks for clarifying!
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 :)
@jobwat Thanks for confirming :-)
@foray1010 @ckiss can you confirm the casing of your username?
my $NVM_DIR is pointed to /usr/local/opt/nvm, installed by brew, OSX 10.11
@foray1010 homebrew isn't supported by nvm - can you try removing it via brew, and installing it properly via the curl command in the readme, and tell me if you still see this problem?
@ljharb Tested, all lower case, nvm is working now!
Awesome, thanks for confirming!
@rudeworks: others with homebrew and this issue have fixed it by brew uninstall nvm, and then properly installing nvm with the curl command in the readme. Can you try this?
That just leaves @fabdrol (probably related to the uppercase char in your username), @mikepaggi (need more info if you're using oh-my-zsh), and @ckiss (need to confirm the casing of your username).
Everyone else so far has resolved the issue - meaning that the prefix warning has done its job :-)
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)
Why is nvm now complaining about prefix for npm? I want my packages where i set them to be...
@seemsindie nvm is not compatible with the prefix option. Global packages should not be shared between node versions - if you want a different location (that nvm does not manage) for these, you'll need to not use nvm.
You're totally right @ljharb, uninstalling and installing via the curl command fixed it for me. Thanks.
@ljharb Ok makes sense, i can't argue that. But how then to manage global installation without sudo, any ideas?
@seemsindie with nvm, npm install -g foo doesn't require sudo, and if you want to reinstall your global modules in another node, nvm install 0.12 --reinstall-packages-from=0.10 or nvm use 0.12; nvm reinstall-packages 0.10.
Sorry i forgot to look back at this :-)
i don't use oh-my-zhs and it seemed to fix my issue once i uninstalled nvm from homebrew and just used the full / normal install. It seemed to mainly be an issue with homebrew now.
@mikepaggi Thanks for confirming!
I'll repeat the tl;dr:
That leaves @fabdrol (probably related to the uppercase char in your username, and/or oh-my-zsh) and @ckiss (need to confirm the casing of your username)
Everyone else so far has resolved their issue - meaning that the prefix warning has done its job :-)
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.
@singlow unfortunately I don't think that's POSIX-compliant - however, if you want to take a stab at using that approach to fix #617 then that'd be helpful :-)
If you install NVM with Homebrew, make sure you don't miss this step:
mkdir ~/.nvm
@bsorem-sugarcrm please do not ever install nvm with homebrew. It's completely unsupported. Install using the curl command in the readme, please.
I ran into the same issue just because I had NVM_DIR="/opt/nvm/" instead of NVM_DIR="/opt/nvm" into my .zshrc .
I ran into this issue on ubuntu 14.04. The issue seemed to be due to NVM_DIR="//home/myuser/.nvm". Somehow changing to NVM_DIR="/home/myuser/.nvm" solved it. My HOME path also had //, so that could be why.
I do not have oh-my-zsh installed and never have, but I still get this error:
$ nvm install 0.12
######################################## 100.0%
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/userName/.node"
Runnpm config delete prefixornvm use --delete-prefix v0.12.7to unset it.
I have tried installing nvm manually and through the install script but in both cases I get the error. I am running npm 3.3.9 from ~/.node/bin/npm and node v4.2.1 from /usr/local/bin/node
@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.
Same Problem here. I'm on OSX 10.10.5, not using zsh.
nvm debug output:
$SHELL: /bin/bash
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v5.0.0
which node: $NVM_DIR/versions/node/v5.0.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.0.0/bin/npm
npm config get prefix: npm ERR! Usage:
npm ERR! npm config set <key> <value>
npm ERR! npm config get [<key>]
npm ERR! npm config delete <key>
npm ERR! npm config list
npm ERR! npm config edit
npm ERR! npm set <key> <value>
npm ERR! npm get [<key>]
npm root -g: $NVM_DIR/node_modules
It says my prefix is '' I don't know if this is a problem and I couldn't find where it is set.
@Eschon It's very strange that npm config get prefix errors out. Do you have an ~/.npmrc file? What's in it? (don't post your authToken please)
I'm getting a similar issue when I try to install an old node version, specifically v0.10.33. I didn't get the issue with 0.10.4x. I'm on Yosemite with bash.
It also tries to read some .pem file i have on my computer.

I just confirmed that any version i install that is v0.10.3x gets me this error. I no longer get the error starting at v0.10.40
Here is another screenshot. 0.10.29 works fine as well.

is there anything in ~/.npmrc that references that PEM file?
YES! That was it! In my .npmrc i set the cafile. When i remove that it works. Weird how in only breaks for v0.10.3x.
You are a wizard.
Awesome! Glad we figured it out.
@ljharb I have a .npmrc file but the only line it contains is save-exact=true
Maybe also relevant:
Changing node version with --delete-prefix works but gives me the following npm errors:
npm ERR! Usage:
npm ERR! npm config set <key> <value>
npm ERR! npm config get [<key>]
npm ERR! npm config delete <key>
npm ERR! npm config list
npm ERR! npm config edit
npm ERR! npm set <key> <value>
npm ERR! npm get [<key>]
npm ERR! Usage:
npm ERR! npm config set <key> <value>
npm ERR! npm config get [<key>]
npm ERR! npm config delete <key>
npm ERR! npm config list
npm ERR! npm config edit
npm ERR! npm set <key> <value>
npm ERR! npm get [<key>]
I also have this problem on osx terminal&omz
I'm experiencing the same issue.
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/0xazure/.dotfiles/nodejs/nvm/versions/node/v4.2.2"
Run `nvm use --delete-prefix v4.2.2 --silent` to unset it.
System:
zsh for my shelloh-my-zsh$ nvm debug
$SHELL: /usr/local/bin/zsh
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:76: command not found: npm
npm root -g: nvm:76: command not found: npm
$ env
PATH=/Users/0xazure/.gvm/pkgsets/go1.5/global/bin:/Users/0xazure/.gvm/gos/go1.5/bin:/Users/0xazure/.gvm/pkgsets/go1.5/global/overlay/bin:/Users/0xazure/.gvm/bin:/Users/0xazure/.gvm/bin:/Users/0xazure/.rbenv/shims:/usr/local/opt/coreutils/libexec/gnubin:/Users/0xazure/.dotfiles/bin:/Users/0xazure/.rbenv/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
LOGNAME=0xazure
XPC_FLAGS=0x0
HOME=/Users/0xazure
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.AG9J4DKQS5/Render
LANG=en_CA.UTF-8
TERM=xterm-256color
USER=0xazure
DISPLAY=/private/tmp/com.apple.launchd.AI9i3uB9vw/org.macosforge.xquartz:0
ITERM_PROFILE=Default
XPC_SERVICE_NAME=0
TERM_PROGRAM=iTerm.app
SHELL=/usr/local/bin/zsh
ITERM_SESSION_ID=w0t0p0
PWD=/Users/0xazure
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
SHLVL=1
OLDPWD=/Users/0xazure
MANPATH=/usr/local/opt/coreutils/libexec/gnuman:
ALTERNATE_EDITOR=
DISABLE_AUTO_TITLE=true
NVM_DIR=/Users/0xazure/.nvm
PAGER=less
LESS=-R
LC_CTYPE=en_CA.UTF-8
LSCOLORS=Gxfxcxdxbxegedabagacad
ZSH_TMUX_TERM=screen-256color
_ZSH_TMUX_FIXED_CONFIG=/Users/0xazure/.dotfiles/zsh/oh-my-zsh/plugins/tmux/tmux.extra.conf
PROMPT_EOL_MARK=
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
NVM_PATH=/Users/0xazure/.nvm/versions/node/v4.2.2/lib/node
NVM_BIN=/Users/0xazure/.nvm/versions/node/v4.2.2/bin
GOROOT=/Users/0xazure/.gvm/gos/go1.5
GOPATH=/Users/0xazure/.gvm/pkgsets/go1.5/global
_=/usr/local/opt/coreutils/libexec/gnubin/env
$ setopt
alwaystoend
autocd
autopushd
cdablevars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
nonomatch
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
$ cat .npmrc
init-author-name=0xazure
init-author-email=<my_email_address>
I can confirm that this only started happening after I updated to v0.29.0 from v.0.26.1.
Like @jaromero, I am symlinking my .nvm directory (that is, ~/.nvm is a soft link to a folder elsewhere on my system). However, I followed the instructions to do a manual install after removing my symlink, and _no longer had the issue above_. Nothing else about the system changed, and I'm still sourcing ~/.nvm/nvm.sh in my .zshrc as follows:
source $HOME/.nvm/nvm.sh
The only thing that had changed (as far as I can tell) was whether ~/.nvm pointed to a symlink or an actual directory.
nvm debug from the manual nvm install:
$ nvm debug
$SHELL: /usr/local/bin/zsh
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v4.2.2
which node: $NVM_DIR/versions/node/v4.2.2/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v4.2.2/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v4.2.2
npm root -g: $NVM_DIR/versions/node/v4.2.2/lib/node_modules
It's good to know about #617, which appears to be the actual root issue, but if that's the case the warning about incompatibility with the "prefix" option is an unexpected side-effect.
@ljharb
it can be reproduce in the following condition:
.nvm is a symbolic linkhttps://github.com/creationix/nvm/blob/master/nvm.sh#L1356
npm config get prefix return real path, NVM_DIR may point to a symbolic path, cause nvm_tree_contains_path fail and then we saw the warning message.
if we resolve NVM_DIR to real path, problem solve.
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)
@kilianc is your $NVM_DIR dir a symlink? If so, #617 is the issue to be posting on.
it's a symlink created with ln -s. Not sure if relevant but ~/ and /Volumes/WS/apps/nvm are on different partitions
Just thought I'd throw in my $0.02. I am running bash on linux, had this problem, and gdelpierre's fix cleared this right up. Seems nvm is kind of picky on how $NVM_HOME is written.
@mrmakeit so yours was also that you had a trailing slash?
Correct
ok - i think i can handle that by stripping off trailing slashes before i do my prefix check. That will hopefully fix at least one class of the issues in this thread.
Try to use this two line in your ~/.zshrc setting
export NVM_DIR=~/.nvm
. "$NVM_DIR/nvm.sh"
nvm use --delete-prefix <your version>
Just fall into this issue this morning.
My config : ElCapitan/bash
I read all this stream to find a way to fix it.
I tried to clear everything related to npm in ~/.local/node_modules/<bin|lib>
I completely reinstall nvm (version 0.30.1)
I still had the issue.
Rehia:~ jerome$ nvm use lts
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/jerome/.local"
Run `nvm use --delete-prefix v4.2.4` to unset it.
Here is the result of my nvm debug command:
Rehia:~ jerome$ nvm debug
nvm --version: v0.30.1
$SHELL: /bin/bash
$HOME: /Users/jerome
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node:
which iojs:
which npm:
npm config get prefix: -bash: npm: command not found
npm root -g: -bash: npm: command not found
-bash: [: : integer expression expected
I finally ran the recommended nvm command:
Rehia:~ jerome$ nvm use --delete-prefix 4
Now using node v4.2.4 (npm v2.14.12)
Then the issue seemed to be fixed, event after a terminal restart:
Rehia:~ jerome$ nvm use 5
Now using node v5.4.1 (npm v3.3.12)
Rehia:~ jerome$ nvm use 4
Now using node v4.2.4 (npm v2.14.12)
Hope it can help others...
@ljharb Is it relevant, that npm has this option by default and as builtin I assume
> npm config list
; cli configs
user-agent = "npm/2.14.14 node/v0.12.7 darwin x64"
; userconfig /Users/xxxxxx/.npmrc
@xxxxxx:registry = "https://npm-private.xxxxxxxx.xx/"
init.author.email = "[email protected]"
init.author.name = "Aleksandr Motsjonov"
; builtin config undefined
prefix = "/usr/local"
; node bin location = /usr/local/bin/node
; cwd = /Users/xxxx/work/r2
; HOME = /Users/xxxxx
; 'npm config ls -l' to show all defaults.
And that's why npm config delete prefix doesn't do much.
I know why I had subj problem. After I installed version 0.10, I've been given this:
npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
npm WARN deprecated latest stable version. To upgrade to npm@2, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm@latest-2
npm WARN deprecated
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm@latest
npm WARN deprecated
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm@2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
And I did installed as instructed. I guess this caused it for me.
npm config get prefix always works, yes - but if you don't have it overridden, it works fine with nvm.
In general, npm should only ever be initially installed as part of node, and node should not be installed via distro package managers.
Hi, I just had the same problem and it had to do with the special setup of the homedir. The /home dir was a link to /data/home.
The .bashrc after installing nvm
export NVM_DIR="/home/insights/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
After changing it to (_/home -> /data/home_)
export NVM_DIR="/data/home/insights/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
I had no longer any problems using nvm use 4.
Maybe it helps anyone...
@irrwitz that's pretty odd - what's echo $HOME output? "/home" and "/data/home" are not standard or conventional paths for a home directory in any OS I'm familiar with.
@ljharb Output of echo $HOME is /home/insights. This setup was done by a previous company and this strange linking has caused problems in other areas too. We will be getting rid of it soon and switch to a standard directory layout.
Ah - if it's a symlink that's definitely not well supported - see #617 for example.
Had this issue from operator error and corrected it.
This works for me :arrow_down:
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
:arrow_up:
What's the best solution to this problem? I have several global modules installed, simply out of their utility. Here are some examples:
I'd rather these kinds of utilities to be symlinked or similar, instead of duplicated several times across Node installations. Cordova and Bower are flat out huge, as large as npm itself (Bower is even larger, IIRC). I would also prefer to be able to upgrade a Node version without having to reinstall everything.
At this point, though, I've also added literally ./node_modules/.bin to my $PATH to alleviate most of the problem with build tools like Gulp, but installing most of the above utilities locally is not intelligent, since they are _standalone programs_, not libraries, frameworks, or build tools like Babel, Express, or Gulp. Also, this doesn't solve the problem that switching Node versions means I have an out-of-date $PATH as well, since there's no way AFAIK in Bash to delay variable expansion in $PATH until it's substituted.
I also frequently use UglifyJS2 as a standalone program to check sizes as well, without actually installing it as a dev dependency. This is helpful when you're writing libraries to get a size estimate, but you're not planning on releasing a minified version with the library itself on npm. I've also found a few bugs in it that way, by just screwing around with the minifier, which I do on occasion.
For the time being, I'm downgrading to 0.26.1 (I upgraded from 0.26.0 earlier today), because this _completely_ broke my local dev workflow.
@isiahmeadows as is said above (and elsewhere in other issue threads), global modules shouldn't be shared across node installations - they may not be compatible, and all of their install scripts need to be rerun every time you switch versions.
I'm sorry that your local dev workflow is incompatible with nvm, but nvm has _never_ worked properly with the npm prefix option - it just now refuses to work in a broken way.
Adding node_modules/.bin to your PATH is insanely dangerous - all locally installed tools should be run via npm run-scripts - but this is a best practice that's not specific to nvm.
I'm not sure why you're concerned about "duplication" - disk space is essentially infinite and free.
The best solution to this problem that isn't "change your workflow" is to not use nvm at all, and to use a single global node version. https://www.npmjs.com/package/n is the best tool for this purpose.
@ljharb I added it to my PATH via my ~/.bashrc, but it's not publicly exported (and npm does that itself within packages, anyways, so I didn't see much harm). It's only sourced in my shell, so that I can also use the locally installed CLI tools easier (I'd rather use mocha --watch with the local mocha instead of a global one). I still use run-scripts/etc. most of the time otherwise, and don't usually run into problems with this workflow.
The reason I'm worried about duplication is because disk space is relatively limited in my computer. Although thanks for telling me about n. That seems to perfectly solve my situation. Thanks! :smile: :+1:
(I'll still be using nvm, since it's a great tool, but I just won't use it as often, since n fills my main use case now.)
@isiahmeadows when npm does it itself, it's in a shell with user nobody so there's no danger.
@ljharb Good point, except it actually can bring out potential security hazards, as well as tons of permissions problems, and also, the default behavior is not to change the GID/UID unless the current user is the root. So it's not going to make a difference in practice, unless you're running npm as root, which is a bad idea to begin with, and fixing those permissions problems is not fun. (It didn't help any that the package in Ubuntu's repos has the shitty default of a global install that requires npm to run as root to globally install anything, making running many of those commands difficult.)
FYI, I just noted on mini-containers/base#5 that I get this error when installing node via nvm on the Docker alpine:3.3 image because the node binary itself has unresolved symbols, since Alpine's musl C library lacks symbols present in Glibc. Somehow, since the binary can't run, nvm reports this as a npm prefix error.
Posting this just in case it happens to explain the problem for some folks here.
I'm sorry to say I get the same issue on a shared hosting linux account.
[ @ljharb: deleted info since it was helpfully moved to https://github.com/creationix/nvm/issues/1034 ]
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!
@javyliu npm config delete prefix should resolve it without pinning you to one node version.
Coming here after doing my best to read through the thread above, but still am stuck. Does anyone have any ideas?
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /Users/Ying
$NVM_DIR: '/Users/ying/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node:
which iojs:
which npm:
npm config get prefix: -bash: npm: command not found
npm root -g: -bash: npm: command not found
Must there be an initial installation of npm/node on the system for this to work? After doing the delete prefix, I get a brief respite:
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /Users/Ying
$NVM_DIR: '/Users/ying/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v5.0.0
which node: $NVM_DIR/versions/node/v5.0.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.0.0/bin/npm
npm config get prefix: $HOME/.nvm/versions/node/v5.0.0
npm root -g: $HOME/.nvm/versions/node/v5.0.0/lib/node_modules
, but the next time i source nvm.sh the problem comes back.
Despite $NPM_CONFIG_PREFIX being '', I still see it when i print out npm config get prefix
/Users/Ying/.nvm/versions/node/v5.0.0
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?
ugh - that fixed it. that was embarassing :disappointed: Thanks a lot for looking into this.
Adding that I'm seeing this bug also. I believe it has something to do with non-standard path of which /Users reside. This is my error output on running nvm.sh on shell start:
nvm is not compatible with the npm config "prefix" option: currently set to "/Volumes/System/Users/[name]/.nvm/versions/node/v5.9.1"
Run nvm use --delete-prefix v5.9.1 --silent to unset it.
@fungilation where does your /Users folder reside?
/Volumes/System/. Already pasted in my last comment
@fungilation and is that a symlink, or a hard mount? if it's a symlink, nvm already has a known issue traversing symlinks.
Symlink.
$ ls -al / |grep Users
lrwxr-xr-x 1 root admin 21 31 Dec 2010 Users -> /Volumes/System/Users
if it's a symlink,
nvmalready has a known issue traversing symlinks.
Is anyone looking into this? I just bumped into it tonight.
$ nvm use node
nvm is not compatible with the npm config "prefix" option: currently set to "/Mounts/Kyarra/Users/nick/.nvm/versions/node/v5.10.1"
Run `nvm use --delete-prefix v5.10.1` to unset it.
$ nvm debug
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /Users/nick
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node:
which iojs:
which npm:
npm config get prefix: -bash: npm: command not found
npm root -g: -bash: npm: command not found
$ nvm use --delete-prefix node
Now using node v5.10.1 (npm v3.8.3)
$ nvm debug
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /Users/nick
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v5.10.1
which node: $NVM_DIR/versions/node/v5.10.1/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.10.1/bin/npm
npm config get prefix: /Mounts/Kyarra$NVM_DIR/versions/node/v5.10.1
npm root -g: /Mounts/Kyarra$NVM_DIR/versions/node/v5.10.1/lib/node_modules
$ ls -al / | grep Users
lrwxr-xr-x 1 root admin 20 Apr 9 09:56 Users -> /Mounts/Kyarra/Users
So is there any working solution for this problem?
@denysdovhan to which? having $NVM_DIR as a symlink, or using the npm "prefix" setting?
@ljharb I have npm prefix as ~/.npm-global. When I type nvm use 4 for example, I will get:
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/denysdovhan/.npm-global"
Run `npm config delete prefix` or `nvm use --delete-prefix v4.4.3` to unset it.
I execute nvm use --delete-prefix v4.4.3, then switch back using nvm use system and after that, if I type npm config get prefix it returns:
/usr/local
Can I escape this reseting somehow?
@denysdovhan no. nvm is incompatible with the prefix setting. You either need to remove this setting (and accept that every node version needs a distinct set of globally installed modules), or you won't be able to use nvm.
Using ubuntu 16 with zsh, exact same problem
alpine linux with bash|zsh
env: can't execute 'node': No such file or directory
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run nvm use --delete-prefix v6.2.0 to unset it.
Any solutions for this?
@Daniel-ltw what does nvm debug output?
it is basically similar to what @nickiaconis had.
The only difference is after I did the whole --delete-prefix, it is still returning
npm config get prefix: -bash: npm: command not found
npm root -g: -bash: npm: command not found
for those two lines.
@Daniel-ltw is $NVM_DIR a symlink, or a hard mount on your user dir, or is your username not all the lowercase while your filesystem is case-insensitive?
$HOME: /home/deploy
Trying to get this up and running.
https://github.com/Daniel-ltw/alpine-rbenv-nvm/blob/master/Dockerfile
Did a docker run with that image and did a nvm install stable.
env: can't execute 'node': No such file or directory
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run nvm use --delete-prefix v6.2.0 to unset it.
Tried switching zsh to bash and it is the same result.
@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.)
nvm afaik is compatible with POSIX, so if alpine isn't then nvm definitely isn't compatible with alpine.
That said, I'm happy to consider any PRs to improve documentation or functionality on that OS.
@mbland
So I could build node and npm from source but not use the binary when use Alpine?
@ljharb I should've been a little more specific: alpine/musl is missing _internal_ symbols plus the non-POSIX backtrace that are baked into Node.js binaries linked against glibc (from https://github.com/mini-containers/base/issues/5#issuecomment-186934231):
Error relocating node: __isinf: symbol not found
Error relocating node: __rawmemchr: symbol not found
Error relocating node: __isnan: symbol not found
Error relocating node: __strtod_internal: symbol not found
Error relocating node: backtrace: symbol not found
@Daniel-ltw To the extent nvm just pulls prebuilt binaries built against glibc, then nvm isn't compatible. Just checking the README, it seems nvm install -s should build from source. I'll try that and report back, lest someone beats me to it; apparently I missed that option earlier.
@mbland installing from source is not currently supported for v1.0 and above.
@ljharb Ah, that rings a bell. I was momentarily astonished that the idea of nvm install -s hadn't occurred to me before, but I guess I'd forgotten that particular fact.
i had this problem today, and in my case was i renamed my home dir from alexandre to Alexandre (because my OCD lol~) i just fixed the home dir reference on my .zshrc export NVM_DIR="/Users/alexandre/.nvm" then the nvm use --delete-prefix v6.3.0 worked just fine (even after new session) -> OSX El Capitain -> ZSH shell
@Dreanmer to clarify, are you saying that the issue went away when your username changed to be all lowercase?
@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;
aha, ok thanks, that makes sense. Certainly if you change your $HOME path, you'd also need to update $NVM_DIR in your profile file.
Same problem here, installed with curl, OSX EL Capitan, comains about
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/sudhir/.node"
Run `nvm use --delete-prefix v6.3.1` to unset it.
And node/npm comands are not found
@snimavat do you have a "prefix" set in ~/.npmrc, specifically that ".node" directory? If so, you'll need to delete that line to use nvm.
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 :-)
This appeared for me on Ubuntu/Arch when I symlinked .nvm dir from another location to my home folder. It seems .nvm doesn't like to be treated that way (many tools don't go well with symlinks), so I added the following bind-ing line to the /etc/fstab:
/home/ikon/configs/.nvm /home/ikon/.nvm none bind 0 0
Now everything is back to normal and the files originally still reside in /home/ikon/configs/.nvm.
I hope it helps someone.
@vadviktor you're correct; see #617 for example
Hi there,
I have the same issue
I'm using ubuntu 16.04
nvm is not compatible with the npm config "prefix" option: currently set to "/home/angel/Projects/node/~/.nvm/versions/node/v6.4.0"
Run `nvm use --delete-prefix v6.4.0` to unset it.
@abr4xas what is echo $HOME? It's very strange that you'd have a "~" in the path - typically "~" is an alias for $HOME.
@abr4xas specifically, if you set NVM_DIR in your profile with a "~", try replacing that with a "$HOME".
@ljharb
echo $HOME
/home/angel
And yes, i have export NVM_DIR="~/.nvm"
@abr4xas if you change that to export NVM_DIR="$HOME/.nvm" your problems will go away.
With MacOS, I had in .bashrc
export NVM_DIR="/Users/nicorama//.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Removing the second slash in /Users/nicorama//.nvm, it works perfecty
I've got this problem in OS X El Capitan, 10.11.6 . The error message doesn't appear to be fixed even on a "temporary" basis via the suggested fixes. I foolishly installed some node version globally while trying to fix this, and also foolishly upgraded npm once in an attempt to fix this, but ran into an entirely different npm bug ( https://github.com/npm/npm/issues/13918 , if you're curious ) before giving up. On the other hand, NVM seems to sorta work anyway...? Maybe?
Here's my .bashrc :
export NVM_DIR="/Users/pingraham/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
On new terminal creation:
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 v5.7.1 --silent to unset it.
node -v
v5.7.1
nvm use 5.7.1
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 v5.7.1` to unset it.
Running either or both of the suggested command doesn't change anything.
Oddly enough, the switch seems to work anyway... maybe...
nvm use 0.10
Now using node v0.10.33 (npm v1.4.28)
node -v
v0.10.33
nvm use 5.7.1
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 v5.7.1` to unset it.
node -v
v5.7.1
(I guess it happened regardless??)
Debugging info:
echo $PREFIX ; echo $NPM_CONFIG_PREFIX
(nothing, just empty lines)
nvm debug
nvm --version: v0.32.0
$SHELL: /bin/bash
$HOME: /Users/pingraham
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: system
which node: /usr/local/bin/node
which iojs:
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules
(nvm debug, after switching)
nvm current: v0.10.33
which node: $NVM_DIR/v0.10.33/bin/node
which iojs:
which npm: $NVM_DIR/v0.10.33/bin/npm
npm config get prefix: $NVM_DIR/v0.10.33
npm root -g: $NVM_DIR/v0.10.33/lib/node_modules
nvm ls
v0.10.33
v5.7.1
-> system
default -> 5.7.1 (-> v5.7.1)
node -> stable (-> v5.7.1) (default)
stable -> 5.7 (-> v5.7.1) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.5.0 (-> N/A)
It seems wrong to just ignore the error! Any ideas on what I could change? And is it a "Real" error, or just noise, since it seems that at least node -v acknowledges the switches anyway?
@peteringraham in your case, do you have a "prefix" line in ~/.npmrc, or anything in env that contains "prefix" (any capitalization)?
@ljharb : Doesn't seem like it.
cat ~/.npmrc| grep prefix
env | grep prefix
Didn't see anything on manual inspection either.
Also PREFIX env vars?
@ljharb : Nope. (Not from manual inspection of env, and not from grep -i .)
There are the nvm debug values above, which are
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
, but to my knowledge that should be expected & fine, right?
One other quick comment if it's relevant: this is in bash, not oh-my-zsh. (I assume this bug is covering the error in general and that it isn't zsh specific, which would be weird.)
@peteringraham yes, if those values are empty that's fine.
I think it would help if you filed a separate issue - this one is actually a combination of multiple problems that lead to this same error.
@ljharb: Filed https://github.com/creationix/nvm/issues/1245 for my symptoms.
+1, getting this on Prezto ( a fork of Oh-My-Zsh ), nvm and trying to install node @ 6.9.0.
I attempted to run nvm use --delete-prefix v6.9.0, which just hangs my terminal window indefinitely..
Any help?
@tconroy what does nvm debug do prior to trying to run nvm use?
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
😀,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/"
@Huibean having the lines in both files shouldn't cause a conflict, altho obviously both should use "$HOME" :-)
@ljharb yes, it should be $HOME in this case, I have checked the install.sh(master), SOURCE_STR convert $HOME to the value before added to my .zshrc, maybe using ${NVM_DIR:-"$HOME/.nvm"} again is better than $INSTALL_DIR in this situation
#line10
nvm_install_dir() {
echo "${NVM_DIR:-"$HOME/.nvm"}"
}
#line 300
SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm\n"
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.
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!
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
@mikedevita is your $HOME (/opt/vApps1/home/mhdevita) being accessed through a symlink or a networked drive by chance?
It is an nfs mounted network drive yes.
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.
I am using oh-my-zsh on OSX 10.12.3 (16D32).
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash $HOME/~/.nvm (not $HOME/.nvm)$HOME/.nvm# doesn't work
export NVM_DIR="~/.nvm"
# i fixed the path
export NVM_DIR="/Users/1ambda/.nvm"
@1ambda try using literal $HOME in your profile. ~ doesn't work in zsh.
I had this issue on Ubuntu 16.04. I tried to install LTS version of node:
user@ubuntu:~$ nvm use 6.9.2
nvm is not compatible with the npm config "prefix" option: currently set to "/home/user/.npm-global"
Run `nvm use --delete-prefix v6.9.2` to unset it.
I had to run only following command to solve the issue:
user@ubuntu:~$ nvm use --delete-prefix v6.9.2 --silent
Now I have node and nvm working as expected:
user@ubuntu:~$ node --version
v6.9.2
user@ubuntu:~$ npm --version
3.10.9
@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. 🎉
I'm seeing this now in Bash for Windows. All was working fine until today after I ran an update on Oh My Zsh. Then this started happening:
`net.js:145
this._handle.open(options.fd);
^
Error: Unknown system error -25: Unknown system error -25, uv_pipe_open
at Error (native)
at new Socket (net.js:145:18)
at createWritableStdioStream (internal/process/stdio.js:156:16)
at process.getStdout [as stdout] (internal/process/stdio.js:10:14)
at module.exports (/home/rey/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/npmlog/node_modules/set-blocking/index.js:2:11)
at Object.
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run npm config delete prefix or nvm use --delete-prefix v6.9.5 --silent to unset it.`
I've tried running the commands mentioned on that last line but no luck. Any thoughts or anything I can do to help you troubleshoot, @ljharb?
@ljharb may I ask what is the problem with supporting a prefix ?
@reybango that looks like an issue with libuv inside npm itself; i'm not sure how to debug that as part of nvm.
@nikoTM the purpose of "prefix" is to override where node looks for global modules. nvm manages your node for you, and thus also needs to manage where node looks for global modules.
@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.
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.
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.
@ljharb this issue is now gone on Bash for Windows using Insider Preview build 15051
thanks @ljharb the install instruction clearly mentions that brew install is not supported. Do not get this with a curl installation as mentioned.
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
@gabfiocchi that shouldn't be necessary; if you run nvm use --delete-prefix v7.10.0 it should unset the prefix for you.
@ljharb yes, but not working right, the unset it's temporal, if you restart o refresh bash profile. You lost the change, and allways need use --delete-prefix v7.10.0
@gabfiocchi if that's the case, then that suggests that your bash profile is setting one of the prefix env vars - you should modify your bash profile so it doesn't do that anymore.
@gabfiocchi solution works for me, think it's because a bunch of profiles that I was using were automatically migrated when I installed oh-my-zsh
@ljharb you are absolutely right, but when it comes to close the terminal and to reopen a new terminal, very annoying issue must be reproduced, so i would like to a ending solution, looking forward to your reply
@liuliangsir reply to which? this is your first comment on this thread.
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.
@encounter see #617 and https://github.com/creationix/nvm/issues/1031#issuecomment-194044829
@ljharb NPM not found when using NVM
@liuliangsir Try nvm alias default node and restart your shell. Is your home dir a symlink? Do you use oh-my-zsh, or have any nonstandard zsh options set?
yeah, i has been using nvm alias default command
nvm ls
-> v4.7.3
v5.5.0
v6.0.0
v7.9.0
v8.1.2
default -> node (-> v8.1.2)
node -> stable (-> v8.1.2) (default)
stable -> 8.1 (-> v8.1.2) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.8.4 (-> N/A)
i restarted my shell again and again
but all things seem to be in vain
Is your home dir a symlink?
i could not understand the upper statement
but i run echo $HOME, then print /Users/liuliang
also i seem not to run ln command
i use oh-my-zsh, but I am not sure that i has set options for zsh
@ljharb i found two similar issue on stackoverflow for example issue 1 and issue 2
@liuliangsir can you file a new issue, and fill out the issue template? This seems like it's a separate problem.
@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"
No, "can you file" is correct. "file" and "open" are a synonym when applied to issues.
Hi , I got this issue:
Every time I reboot, node & npm command not found
Here is my "nvm debug"
➜ ~ nvm debug
nvm --version: v0.33.2
$SHELL: /bin/zsh
$HOME: /home/choyt
$NVM_DIR: '$HOME/.nvm/'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.1.1 (x86_64-ubuntu-linux-gnu)'
uname -a: 'Linux 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 16.04.3 LTS
curl: /usr/bin/curl, curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.17.1 在 linux-gnu 上编译。
git: /usr/bin/git, git version 2.7.4
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:143: command not found: npm
npm root -g: nvm:143: command not found: npm
System: ubuntu 16.04
bash: oh-my-zsh & terminal
@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 :-)
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
@ljharb thank you a lot, you save my day!
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.
Certainly using brew to install node has broken things for a lot of people; thanks for that suggestion.
uninstall node version(broken), and reinstall node version.
here is a example:
nvm uninstall v4.7.3 && nvm install v4.7.3
@bryansray thanks, exactly what I needed.
For me, the issue was happening only on zsh+oh-my-zsh+tmux. Was not happening on zsh+oh-my-zsh.
I was able to fix it after uninstalling a node@6 version that was installed using homebrew.
@bryansray Worked for me. Thanks.
@bryansray Thanks! Yeah, brew install yarn also installs Node.js.
To fix the problem I had to: brew uninstall node
Same issue, got that message on every new tab =>
"nvm is not compatible with the npm config "prefix" option: currently set to "/Users/Djamal/.nvm/versions/node/v8.9.1"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.9.1 --silent` to unset it."
$ which npm : /usr/local/bin/npm
$ which node : /usr/local/bin/node
@fenek5 what does whoami say? Is your home dir, or $NVM_DIR, a symlink or a hard mount?
My home directory is a symlink and I have this issue, what is the fix and why is this an issue in the first place? Many people commenting with no clear resolution.
I do not have an npmrc at all, did not configure nvm or npm in any special way. Installed nvm initially when home directory was not a symlink, moved the home directory to another partition and symlinked it and started having this issue.
nvm is not compatible with the npm config "prefix" option: currently set to "/big/home/host/.nvm/versions/node/v8.9.1" Run `nvm use --delete-prefix v8.9.1 --silent` to unset it.
Deleted .nvm and reinstalled nvm, getting this upon attempting to install a node:
tk% nvm install 9 Downloading and installing node v9.2.0... Downloading https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz... ######################################################################## 100.0% Computing checksum with sha256sum Checksums matched! nvm is not compatible with the npm config "prefix" option: currently set to "/big/home/host/.nvm/versions/node/v9.2.0" Run `nvm use --delete-prefix v9.2.0` to unset it.
Clearly I didn't set that option, node isn't even installed yet at this point.
It seems that the workaround for this is rather simple: put this into .zshrc etc. as the error message says:
nvm use --delete-prefix v8.9.1
Nvm still complains but now functions.
If you are using more than one node version you could put nvm use --delete-prefix into a shell alias.
The real workaround is not to make a critical dir like your home dir be a symlink :-/ alternatively, you could set NVM_DIR to the real path of $HOME/.nvm, instead of the symlinked path?
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
@sunyazhou13 that opt implies you installed nvm with homebrew, which is unsupported. If so, please brew uninstall it and install it properly via the curl/wget command in the readme.
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.
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
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"
...
@argshook Thank you! That worked for me too!
Getting a similar issue and not sure how to fix it
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 v6.11.5 --silent to unset it.
@OrrYakobi Do you have NVM installed ?
I have the same issue on openSUSE Linux 42.3.
I cloned the repository and placed it in my software directory: ~/Software, and then soft linked the entire directory into my home folder as a hidden directory:
ln -s ~/Software/nvm ~/.nvm
Using the recommended ~/.bashrc line caues issues, but if you change the value of $NVM_DIR to it's actual location (in my case ~/Software/nvm), then there is no problem and I can use nvm as normal
@westeross I do have NVM installed
@cbcoutinho the nvm dir can not be a symlink. That's a separate issue.
@ljharb oops you're right, I was only paying attention to the error message I was getting and that it's identical to the one in this issue. You're right, it's not related.
i also facing same issue, seem like some work for others, some doesnt, did i have to try one by one..
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.
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. 🤠
when I soft link ~/.nvm to ~/.dotfiles/nvm, I get then same issues in omz
@xqbumu ~/.nvm isn't a dotfile, it's a directory.
change "export NVM_DIR=~/.nvm" to absolute path "export NVM_DIR=/Users/myname/.nvm" in .zshrc file worked for me.
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
Don't know why, but @doosenn solution worked for me. I'm on Ubuntu and using zsh with oh-my-zsh
@dan-j's solution solved my problem
This issue showed up out of nowhere today for me. Not sure what changed. I am running arch and using oh-my-zsh.
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.
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).
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)
"terminal.integrated.shellArgs.osx": []bash-[versionNumber]$.bashrc or .bash_profile:export PS1='$(hostname -s):${PWD##*/} $(whoami)\$ '@dan-j solved my problem。 thanks!
@reallistic solved my problem I needed the brew uninstall --force node and brew prune
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
@jiangmiao #1031 may be related.
@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.
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.
thanks @dan-j this saved my life. somehow started I think when I brew installed yarn...not sure 🤷♂️ but popped up out of the blue
Happens to me when I have mounted $HOME on external drive with oh-my-zsh @doosenn solution worked for me. I had to change $HOME/.nvm to absolute path. Thanks!
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!
@ADiesel82 in addition, you may want to brew uninstall nvm, and install it using the supported method in the readme.
Sigh, I've tried all of these I think.
I use zsh with oh-my-zsh, but it does the exact same thing with bash.
nvm installed via:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
yarn was installed with brew, so I uninstalled the node 10.3 that it installed as recommended above. That doesn't make npm very happy.
I change NVM_DIR to an absolute path.
export NVM_DIR="$HOME/dotfiles/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Every single time I open a new shell:
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/crucialfelix/dotfiles/nvm/versions/node/v6.9.1"
Run `npm config delete prefix` or `nvm use --delete-prefix v6.9.1 --silent` to unset it.
~ ❯ nvm use --delete-prefix v6.9.1 --silent ⏎
~ ❯ nvm use ten
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/crucialfelix/dotfiles/nvm/versions/node/v10.1.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v10.1.0` to unset it.
~ ❯ nvm use --delete-prefix v10.1.0 ⏎
Now using node v10.1.0 (npm v6.1.0)
~ ❯ nvm use ten
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/crucialfelix/dotfiles/nvm/versions/node/v10.1.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v10.1.0` to unset it.
~ ❯ nvm use --delete-prefix v10.1.0 ⏎
Now using node v10.1.0 (npm v6.1.0)
~ ❯ node --version
v10.1.0
~ ❯ which node
/Users/crucialfelix/.nvm/versions/node/v10.1.0/bin/node
bash-3.2$ nvm debug
nvm --version: v0.33.11
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 2
$HOME: /Users/crucialfelix
$NVM_DIR: '$HOME/.nvm'
$PATH: $NVM_DIR/versions/node/v10.1.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin:$HOME/bin:$HOME/.rvm/bin:$HOME/.rvm/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin17.0)'
uname -a: 'Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.3 17D102
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: /usr/local/bin/wget, GNU Wget 1.19.5 built on darwin17.5.0.
git: /usr/bin/git, git version 2.15.1 (Apple Git-101)
grep: /usr/bin/grep, grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
rm: /bin/rm,
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir,
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: v10.1.0
which node: $NVM_DIR/versions/node/v10.1.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v10.1.0/bin/npm
npm config get prefix: $HOME/dotfiles/nvm/versions/node/v10.1.0
npm root -g: $HOME/dotfiles/nvm/versions/node/v10.1.0/lib/node_modules
@crucialfelix is your home dir, or nvm dir, by chance a symlink or some kind of filesystem mount?
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
@crucialfelix see #1031 and #617
Just ran into this problem starting Friday. I don't use omz, but I am extending zim with my own custom dotfiles.
I'm running OSX High Sierra, and here is the nvm debug output:
nvm debug
nvm --version: v0.33.11
$TERM_PROGRAM: iTerm.app
$SHELL: /usr/local/bin/zsh
$SHLVL: 7
$HOME: /Users/alex
$NVM_DIR: '$HOME/.nvm'
$PATH: $HOME/.yarn/bin:$HOME/.rbenv/shims:$NVM_DIR/versions/node/v9.11.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.yarn/bin:$HOME/.rbenv/shims:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:$NVM_DIR/versions/node/v9.11.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:$HOME/work/kelle-mobile-app/node_modules/.bin:$HOME/.bin:$HOME/Library/Android/sdk/tools:$HOME/Library/Android/sdk/platform-tools:$HOME/.bin:$HOME/Library/Android/sdk/tools:$HOME/Library/Android/sdk/platform-tools
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.4.2 (x86_64-apple-darwin16.7.0)'
uname -a: 'Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64 i386'
OS version: Mac 10.13.5 17F77
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: not found
git: /usr/local/bin/git, git version 2.15.1
grep: grep: aliased to grep --color=auto (grep --color=auto), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
rm: /bin/rm,
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir,
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: v9.11.1
which node: $NVM_DIR/versions/node/v9.11.1/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v9.11.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v9.11.1
npm root -g: $NVM_DIR/versions/node/v9.11.1/lib/node_modules
Definitely some weird stuff in there (illegal option -- - a lot).
I installed via the curl script, v0.33.11.
I don't have a /usr/local/bin/node, so I think that rules out at least one fix mentioned in the thread.
I'm not mounted on any separate partitions, but I do have a case-sensitive partition mounted in a subdirectory in my home folder.
Here is the output from setopt:
alwaystoend
autocd
autopushd
autoresume
nobgnice
nocaseglob
nocheckjobs
noclobber
extendedglob
extendedhistory
histignorealldups
histignoredups
histignorespace
histsavenodups
histverify
nohup
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
nonomatch
pathdirs
nopromptsp
promptsubst
pushdignoredups
pushdsilent
pushdtohome
sharehistory
shinstdin
zle
Looks like I installed yarn via curl -o- -L https://yarnpkg.com/install.sh | bash, since doing brew uninstall yarn gave me No such keg.
I uninstalled yarn by removing it from my PATH and deleting ~/.yarn, installed with brew --without-node, as mentioned in their docs. Still no dice.
I did brew uninstall --ignore-dependencies --force node, which was suggested above, still no success.
This problem only started after opening a new shell on Saturday, did an update on Friday (which was for xcode cli tools, and garage band, nothing that screams general shell to me).
Otherwise, I've had no change in my config for a number of months now. I don't mind running that unset command in new shells for now via a zsh script, but that seems counter-productive, since it appears the problem is with the mechanism nvm uses to set the node path.
Update: I get this problem with iTerm2 Build 3.1.6, but not when I use hyper.
@mrozbarry do you have any custom character encodings, or similar, set in iTerm?
Either way, I think you have a different issue, so it'd be great if you could move this to a new one :-)
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
useexport NVM_DIR=$(realpath "$HOME/.nvm")
it is solved
Same here.
I also meet the same problem:
Last login: Wed Jul 18 15:34:39 on ttys000
nvm is not compatible with the npm config "prefix" option: currently set to "/Users/fenghelong/.npm-global"
Run `nvm use --delete-prefix v10.6.0 --silent` to unset it.
TMPDIR=/var/folders/b_/k5znmjj16hzdj3v7zdlx1w8m0000gp/T/
XPC_FLAGS=0x0
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.FE6rHBehfZ/Render
TERM_PROGRAM_VERSION=404
LANG=zh_CN.UTF-8
TERM_PROGRAM=Apple_Terminal
XPC_SERVICE_NAME=0
TERM_SESSION_ID=B341ADFF-BC25-4CD2-9E83-9FA0437FE857
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.63vgI8ASeV/Listeners
TERM=xterm-256color
SHELL=/bin/zsh
HOME=/Users/fenghelong
LOGNAME=fenghelong
USER=fenghelong
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
SHLVL=1
PWD=/Users/fenghelong
OLDPWD=/Users/fenghelong
ZSH=/Users/fenghelong/.oh-my-zsh
PAGER=less
LESS=-R
LC_CTYPE=zh_CN.UTF-8
LSCOLORS=Gxfxcxdxbxegedabagacad
AUTOJUMP_SOURCED=1
AUTOJUMP_ERROR_PATH=/Users/fenghelong/Library/autojump/errors.log
NVM_DIR=/Users/fenghelong/.nvm
NVM_CD_FLAGS=-q
_=/usr/bin/env
nvm debug
nvm --version: v0.33.11
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
$HOME: /Users/fenghelong
$NVM_DIR: '$HOME/.nvm'
$PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin17.0)'
uname -a: 'Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.5 17F77
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: /usr/local/bin/wget, GNU Wget 1.19.5 在 darwin17.5.0 上编译。
git: /usr/bin/git, git version 2.15.2 (Apple Git-101.1)
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
rm: /bin/rm,
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir,
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:173: command not found: npm
npm root -g: nvm:173: command not found: npm
alwaystoend
autocd
autopushd
combiningchars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
nonomatch
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
and I also run this command to avoid npm permission issue.
npm config set prefix '~/.npm-global'
related to this post
@tolerious because you have a prefix line in ~./npmrc. Delete it.
@ljharb I set prefix to avoid permission issue related to this post
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.
I realised, that this behaviour connected with commitizen
when I simply run git commit -am "msg" - all hooks run fine
when I run git-cz - I get
nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/rifler/.nvm/versions/node/v10.6.0"
Run `unset npm_config_prefix` to unset it.
husky > can't find npm in PATH, skipping precommit script in package.json
nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/rifler/.nvm/versions/node/v10.6.0"
upd:
it is connected with husky package too, so updating to husky@next solved my problem
@rifler looks like you commented on another issue, and this reply addresses it
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
@Xiongqi-XQ nvm doesn't support traversing symlinks, so that's not going to work well, and is poor advice. global modules should truly live inside NVM_DIR. I'm going to hide both our comments so it's harder for people to accidentally implement your suggestion.
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
@ceccode i suspect that’s a different problem, related to the files tmux is sourcing. Can you file a separate issue?
Worth noting that @ADiesel82's solution worked for me https://github.com/creationix/nvm/issues/855#issuecomment-392507347
I'm commenting here because it's very difficult to find fixes in github threads. The thumbsup system is lacking.
@jcollum that very info is in the readme; i'd suggest starting there before trying to find fixes in github threads :-)
Using Zsh with oh-my-zsh and this issue of
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 v10.8.0 --silent` to unset it.
still persists. Even with nvm use --delete-prefix v10.8.0 --silent in the .zshrc file, i still get the message every time I open a terminal. Very annoying. How do I fix it?
just nvm use node
@reallistic explains the root cause of this behavior above, and a great solution. I also noticed that when you run brew update && brew upgrade it might reinstall brew's version of node depending on the dependency tree (which looks like yarn is the main culprit), even when you are already using nvm's node. This brings back the conflict after already using @reallistic's solution. When that happens, just re-do the fix steps. Just fyi.
brew uninstall --ignore-dependencies node solved it for me as I had an old version of node lying around.
The same on linux.
Even if prefix is set to something like ~/.npm-global issue is present. (it also present if there's no prefixes at all)
Also if I use "recommended" nvm use --delete-prefix v10.12.0 then nvm sets node to current version installed, but running it will end with segmentation fault (core dumped), however running it by the full path like /home/user/.nvm/versions/node/v10.12.0/bin/node works well.
PS: there's no system nodejs version installed. only nvm.
@SkeLLLa certainly you don't want to ever use "prefix"; the segfault seems like a serious issue (note that node 10 no longer supports 32 bit machines on linux), altho that'd be coming from npm not from node.
@ljharb I've resolved issue with segfaults. The problem was that if node is launched like node not with full path it take wrong so files and got segfault.
As for prefix issue - I've just tried to add it in order to try to resolve issue. I never set it before installing nvm. So it was installed on clean system with zsh. And when I tried to switch node version to one that I've installed it promted about prefix.
I've tried to delete that prefix with npm config and that didn't work. Later I tried to manually set it in .npmrc and that also not resolved this issue.
node by itself should be sufficient; if that doesn't work, what does which node print out?
@ljharb it will print /home/user/.nvm/versions/node/v10.12.0 and as I said if I use just node it will tried to load some .so libs from /usr directory. I think because on linux it's default path for libs and node searches dynamic libs there by default. That was the problem.
hm, that doesn't make much sense to me; if which node is an nvm-installed node, then node should work, with or without the full path.
I also got this error when using prezto. I uninstalled system node and the error does not appear again.
[EDIT:]
:) For now I migrate to nodenv.
Hi @ljharb I have the same issue and I'm not sure which fix steps to follow. Could you please help?
thanks.
~ nvm deactivate ; nvm debug ; echo $PREFIX ; echo $NPM_CONFIG_PREFIX
Could not find /Users/donaral/.nvm/*/bin in $PATH
nvm --version: v0.33.11
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
$HOME: /Users/donaral
$NVM_DIR: '$HOME/.nvm'
$PATH: $HOME/.rvm/gems/ruby-2.4.1/bin:$HOME/.rvm/gems/ruby-2.4.1@global/bin:$HOME/.rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.rbenv/shims:$HOME/Library/android-sdk/tools:$HOME/Library/android-sdk/platform-tools:$HOME/.rvm/gems/ruby-2.4.1/bin:$HOME/.rvm/gems/ruby-2.4.1@global/bin:$HOME/.rvm/rubies/ruby-2.4.1/bin:$HOME/.rvm/bin:$HOME/Library/Android/sdk/tools:$HOME/Library/Android/sdk/platform-tools:$HOME/.rvm/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin17.0)'
uname -a: 'Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.6 17G65
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: not found
git: /usr/bin/git, git version 2.15.2 (Apple Git-101.1)
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
rm: /bin/rm,
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir,
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: system
which node: /usr/local/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
env
TERM_SESSION_ID=w0t0p0:87954B49-8844-40A2-80CC-942319E7CCDF
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.NXLb2K9P76/Listeners
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.Kt9G9Sskzo/Render
COLORFGBG=7;0
ITERM_PROFILE=Default
XPC_FLAGS=0x0
LANG=tr_TR.UTF-8
PWD=/Users/donaral
SHELL=/bin/zsh
SECURITYSESSIONID=186a8
TERM_PROGRAM_VERSION=3.2.5
TERM_PROGRAM=iTerm.app
PATH=/Users/donaral/.rvm/gems/ruby-2.4.1/bin:/Users/donaral/.rvm/gems/ruby-2.4.1@global/bin:/Users/donaral/.rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/donaral/.rbenv/shims:/Users/donaral/Library/android-sdk/tools:/Users/donaral/Library/android-sdk/platform-tools:/Users/donaral/.rvm/gems/ruby-2.4.1/bin:/Users/donaral/.rvm/gems/ruby-2.4.1@global/bin:/Users/donaral/.rvm/rubies/ruby-2.4.1/bin:/Users/donaral/.rvm/bin:/Users/donaral/Library/Android/sdk/tools:/Users/donaral/Library/Android/sdk/platform-tools:/Users/donaral/.rvm/bin
COLORTERM=truecolor
COMMAND_MODE=unix2003
TERM=xterm-256color
HOME=/Users/donaral
TMPDIR=/var/folders/64/r3kkflld5yx190dx8_zc037h0000gp/T/
USER=donaral
XPC_SERVICE_NAME=0
LOGNAME=donaral
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
ITERM_SESSION_ID=w0t0p0:87954B49-8844-40A2-80CC-942319E7CCDF
SHLVL=1
OLDPWD=/Users/donaral
ZSH=/Users/donaral/.oh-my-zsh
PAGER=less
LESS=-R
LC_CTYPE=tr_TR.UTF-8
LSCOLORS=Gxfxcxdxbxegedabagacad
VIRTUAL_ENV_DISABLE_PROMPT=1
NVM_DIR=/Users/donaral/.nvm
NVM_CD_FLAGS=-q
rvm_prefix=/Users/donaral
rvm_path=/Users/donaral/.rvm
rvm_bin_path=/Users/donaral/.rvm/bin
rvm_version=1.29.3 (latest)
GEM_HOME=/Users/donaral/.rvm/gems/ruby-2.4.1
GEM_PATH=/Users/donaral/.rvm/gems/ruby-2.4.1:/Users/donaral/.rvm/gems/ruby-2.4.1@global
MY_RUBY_HOME=/Users/donaral/.rvm/rubies/ruby-2.4.1
IRBRC=/Users/donaral/.rvm/rubies/ruby-2.4.1/.irbrc
RUBY_VERSION=ruby-2.4.1
ANDROID_HOME=/Users/donaral/Library/android-sdk
JAVA_HOME=/usr/bin
RBENV_SHELL=zsh
rvm_alias_expanded=
rvm_bin_flag=
rvm_docs_type=
rvm_gemstone_package_file=
rvm_gemstone_url=
rvm_niceness=
rvm_nightly_flag=
rvm_only_path_flag=
rvm_pretty_print_flag=
rvm_proxy=
rvm_quiet_flag=
rvm_ruby_bits=
rvm_ruby_file=
rvm_ruby_make=
rvm_ruby_make_install=
rvm_ruby_mode=
rvm_script_name=
rvm_sdk=
rvm_silent_flag=
rvm_use_flag=
rvm_wrapper_name=
LS_COLORS=di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:
GREP_COLOR=1;33
rvm_hook=
_system_type=Darwin
_system_name=OSX
_system_version=10.13
_system_arch=x86_64
_=/usr/bin/env
@donaral try removing your system node
@ljharb thanks, that worked!
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.
@HermitCarb that works for you because you have the “npm_config_prefix” environment variable set somehow - something else in your profile is setting it. Your fix works, but a better one would find and remove the place that sets it, rather than setting it and then unsettling it.
brew uninstall --ignore-dependencies nodesolved it for me as I had an old version of node lying around.
it works for me thanks!
https://github.com/creationix/nvm/issues/855#issuecomment-147127139
What if you try
export NVM_DIR="/Users/isaac/.nvm"?I've added
$HOMEinfo tonvm debugin c957989 to hopefully try to catch this sooner next time :-)
@ljharb This fixed it for me! Must be something to do with ~/ in zsh? 🤔
What if you try
export NVM_DIR="/Users/isaac/.nvm"?
I've added$HOMEinfo tonvm debugin 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
for vscode (or any editor), i believe you'd need to find a way to configure it to use a login shell.
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.
Upgrading nvm to v0.34.0 has fixed the issue for me. 🎉
Upgrading nvm to v0.34.0 has fixed the issue for me. 🎉
Noob question but how did you upgrade to nvm v0.34 ?
@sinharaksh1t rerun the install command in the readme (in general, for all software that doesn't specify otherwise, "install the latest in-place" is the proper way to upgrade)
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
@sinharaksh1t that's just fine; try closing and reopening your terminal (as the install script indicates)
@ljharb tried that. Also restarted the computer and did nvm --version again. Still seeing the same version v0.33.11
Let’s file a separate issue to discuss that then; that sounds more complicated.
~/.zprofile#######################################################
# for nodejs nvm:
#######################################################
# fix:
nvm use --delete-prefix default
source ~/.zprofilezsh .brew uninstall --force node
source ~/.zprofile again.If you are setting an NPM env variable in your .zshrc (but I guess it is the same also for .bashrc), like NPM_TOKEN, make sure you do it right after export NVM_DIR="$HOME/.nvm"
@Pipeman it shouldn't matter what order you set npm vars, unless you're trying to set the prefix (in which case, don't do that)
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
Hmm, $HOME usually never has a trailing slash; i think that’d be your real issue.
Thought I would paste this incase someone finds it useful, i'm using oh-my-zsh
I couldn't add [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh --no-use" to my .zshrc so I added if [ -s "$NVM_DIR/nvm.sh" ]; then . ~/.nvm/nvm.sh --no-use; fi
That worked for me
@ljharb
Hmm, $HOME usually never has a trailing slash; i think that’d be your real issue.
You are right. I checked on other Linux systems and $HOME does not have a trailing slash. Not sure why mine has one though.
@alextrastero why can't you add the proper line to your zshrc?
@alextrastero why can't you add the proper line to your zshrc?
I get this error: no such file or directory: /Users/alextrastero/.nvm/nvm.sh --no-use.
Thought it might be related to how oh-my-zsh passes arguments to commands
@alextrastero if /Users/alextrastero/.nvm/nvm.sh exists, then it's definitely an omz issue.
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 runningnvm --version, I'm still seeing v0.33.11
it works for me
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
解决问题.
Upgrading solved the problem for me, thanks. 😄
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
@vegetabill specifically, nvm does not support the home dir being a symlink (and many other tools may not either). I'd suggest to your org's dev ops team that they use a hard link or a mount, rather than a symlink.
Hello and good day.
yeah I am here cause I am facing the same issue with nvm installation. Here are my details:
dell@dell-Inspiron-5567:~$ nvm use 12
nvm is not compatible with the npm config "prefix" option: currently set to "/home/dell/.npm"
Run npm config delete prefix or nvm use --delete-prefix v12.13.0 to unset it.
dell@dell-Inspiron-5567:~$ npm config get prefix
/home/dell/.npm
So not sure if this helps and quite new to node and npm but, one of the things that I read is that you should not use sudo command to install global level npm packages and then I came across using prefix. So I made the changes in my system.
But not helping post installation of nvm and version 12 with nvm.
Any ideas (perhaps step by step) on what we can do?
@sricharankrishnan remove the prefix line in ~/.npmrc
@ljharb : thank you so much for your assistance. This worked. Also just wanted to check, now I gave the command nvm use 12 so it switched to node version 12.x.x....
i have global packages installed in my system so will they work when I am making switches or do i need to do something more like re-installing them? Please help...
They will work if they're not shadowed (but you generally shouldn't have anything globally installed at all).
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 prefixbefore loading nvm doesn't change the output ofnpm 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
-lflag (which makes it a login shell) interminal.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. 🎉
I have the same problem. and resolved as follows.
$ vi ~/.bash_profile
...
export NVM_DIR="/User/Falsy/.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=/Users/Falsy/.nvm/versions/node/v12.14.0/bin:$PATH
(Where 'Falsy' is the my computer username.)
@falsy assuming whoami prints out Falsy, and echo $HOME also matches the capitalization, I'm not sure why you're running into that problem. You should not have to manually configure the PATH.
@ljharb that's right. this is not an exact solution. i have two macOS computers. this problem only occurs on one of them. the difference between the two computers is that the computer in question is logged in as a newly added user instead of an existing admin user.
i'm not exactly sure what caused this problem. i hope my guess helps a bit.
finally, i'm always using nvm well. thank you.
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.
@fabdrol have you solved your issue, or is it still a problem?
I am having the same issue on an Amazon Linux 2 cloud machine. I am also using zsh and oh-my-zsh.
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.
Upgrading to the latest version of
nvmfixed the issue for me (0.35.3). As a precaution, I removed the~/.nvmdirectory and installed fresh versions of Node.js using the updatednvm.See https://github.com/nvm-sh/nvm for instructions.
Updating fixed this issue for me as well.
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...
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

If anyone has a fix for this, I'd appreciate it. I've tried suggestions up here, but didn't work.
If I add which npm before nvm path is set, I get npm not found.
For now I have just added the line nvm use --delete-prefix v14.5.0 to my .zshrc file so it works automatically. It's just an annoyance to keep seeing the error each time.
UPDATE: Noticed weird behavior. If I run Visual Studio Code, I do see the node version.
/usr/local/opt/nvm/versions/node/v14.5.0/bin/npm
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/nvm/0.35.3/versions/node/v14.5.0"
Run `nvm use --delete-prefix v14.5.0 --silent` to unset it.
Now using node v14.5.0 (npm v6.14.5)
Not sure why, or if it can help trace the problem.
@basharabdullah you installed nvm via brew - i do not support installs via homebrew. Try removing it and reinstalling nvm the only proper way, the curl script in the readme. (this tends to fix this particular issue for many users)
I have the problem and I've tried different solutions but it didn't work for me
`➜ nvm use
Found '/Users/Fakename/folder/myspace/project-name/.nvmrc' with version <10.17.0>
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '"/Users/Fakename/Library/Application'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at Module._preloadModules (internal/modules/cjs/loader.js:901:12)
at preloadModules (internal/bootstrap/node.js:602:7)
at startup (internal/bootstrap/node.js:273:9)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run nvm use --delete-prefix v10.17.0 to unset it.`
@infantito please file a new issue for that, and fill out the full template. Thanks!
@vegetabill specifically, nvm does not support the home dir being a symlink (and many other tools may not either). I'd suggest to your org's dev ops team that they use a hard link or a mount, rather than a symlink.
I'm on FreeBSD, where /home is a symlink to /usr/home by default, effectively triggering the error regarding the prefix, probably for each and every FreeBSD installation (and potentially other Unix flavors) out there.
Disallowing symlinks within one's home path thus doesn't seem to be a very portable way of looking at things.
Maybe stuff like readlink -f and/or pwd -P might help to create more portable scripts.
@olivermg that's new information for me, and quite unfortunate, but I'm very surprised that over the 6-8 years nvm has been around, no FreeBSD user has reported this before :-/
See #2143 and #617 for things relevant to symlinks.
@ljharb For more info, I've just installed a few recent BSDs in VMs:
All the following FreeBSD installations set /home to a symlink to /usr/home, while also setting $HOME to /home/myuser (chshing from the default shell _sh_ to _bash_ does not seem to make a difference to the value of $HOME):
The following BSDs don't seem to use symlinks in home paths though:
@ljharb Btw, if it's coming in handy for you I can start working on a PR regarding this issue (i.e. supporting OSes that do use symlinks in home paths).
Moreover, this is probably a new distinct issue, as it is not related to zsh.
UPDATE: I understand there is already a PR going into this direction in #2143 . Let's see if your request for finishing that PR actually triggers a response ;-) . If not I'll maybe look into it.
@olivermg it would also be awesome if you wanted to just comment on #2143 with a link to your own branch that builds off of it - i can easily pull in those commits, even if the OP doesn't respond. I'd love to improve the workflow here, just because nvm hasn't worked with symlinks for awhile doesn't mean it doesn't suck that it doesn't :-)
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).
@sricharankrishnan remove the prefix line in ~/.npmrc
Cannot change root .npmrc as it is locked for change.
@AnshulSurana that's not the root npmrc, that's your user npmrc, and you should always have full control of anything in ~. If you can't remove that line, then unfortunately you can't use nvm, because the two things are incompatible.
I do not use oh-my-zsh, I use ZimFW, but I'll still tag along because I think it's related.
My flavor of this is pretty damn weird. When I open a terminal, I get:
grep: Desktop: Is a directory
grep: Downloads: Is a directory
...etc
This also happens on TTY, with no graphical server running at all.
In specific directories, I get weird stuff, like:
grep: node_modules: Is a directory
grep: out: Is a directory
grep: src: Is a directory
grep: static: Is a directory
(eval):1: command not found: forge.config.js
nvm is not compatible with the "README.md:- [`forge.config.js`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)" environment variable: currently set to ".md:- [](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)"
Run `unset README.md:- [\`forge.config.js\`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)` to unset it.
Of course, the sentence
- [`forge.config.js`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)
is part of my README.md and describes the project's architecture.
The string forge.config.js only exists in the README.md and as a config key in `package.json.
> grep -R "forge.config.js" --exclude-dir node_modules
package.json: "forge": "./forge.config.js"
README.md:- [`forge.config.js`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)
If I remove that sentence from the README, then nvm tells me this:
nvm is not compatible with the "package.json: "forge": "./forge.config.js"" environment variable: currently set to ".json: forge: ./forge.config.js"
If I remove _that_, then I only get the directories issues described above. Removing only the line in package.json isn't sufficient, however.
So nvm is deciding on its own to... parse the README.md, extract that string for some reason, then eval it? Then decide that there's an environment variable equal to the whole line?
Notice the environment variable's name starts with README.md: ... but it's set to .md: ...
I can confirm these issues come from nvm, because if I do not source nvm.sh, I get none of this. Using bash fixes the problem too, so this some kind of mix between nvm and zsh.
Apart for these annoying notices, nvm is working as expected, as far as I can tell.
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?
Most helpful comment
for future wanderers:
i had to
rm /usr/local/bin/npmso that the one from within nvm would be used and not something i installed ages ago globally