Skip to content

NVM is not compatible with the npm config "prefix" option warning (OS X) #1245

Closed
@peteringraham

Description

@peteringraham

Split off from #855 ; see that issue for a similar problem.

This is in OS X El Capitan, 10.11.6 . This error appears on starting a new shell:

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.

With the usual command in the .bashrc file:

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

Running either or both of the suggested fixes don't appear to do anything, though.

Note: 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 ( npm/npm#13918 , if you're curious ) before giving up. On the other hand, NVM seems to sorta work anyway...? Maybe?

Here's some commands & their results:

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)

No prefixes set in the environment, either:

$PREFIX: ''
$NPM_CONFIG_PREFIX: ''

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?

Activity

ljharb

ljharb commented on Sep 26, 2016

@ljharb
Member

(also per #855 (comment), you don't have any "prefix" in any .npmrc files, and per #855 (comment), you don't have any case-insensitive form of "prefix" in env)

I assume that nvm ls, after the nvm use, has the -> pointing at "v5.7.1"?

Do you have anything in ~/.bash_profile and/or ~/.bashrc that refers to PATH, nvm, or npm?

I'm seeing a few strange things here:

  • nvm use complains about the prefix, but you don't have any prefix overrides set anywhere
  • when nvm use complains about the prefix, the node version still changes (it should be running nvm deactivate after printing that error)
peteringraham

peteringraham commented on Sep 26, 2016

@peteringraham
Author

I don't believe so, as far as PATH /nvm / npm references of note. My ~/.bash_profile:

source ~/.bashrc

if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi

The source of the bashrc seems like it shouldn't really be necessary to me, but .bashrc doesn't run if I don't include it.

The only thing in .bashrc of potential interest is pretty bog-standard:

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

eval "$(grunt --completion=bash)"

For nvm ls: Not that one version. If I use 5.7.1, it points to "system" instead (which is hopefully harmless, since node -v indicates system IS 5.7.1 ). npm -v says it is 3.6.0. If I use some other version (e.g. v.0.10.36), then it points to that, yes (and npm -v gives 2.20 ).

(after terminal start, or nvm use 5.7.1)

nvm ls
       v0.10.33  
       v0.10.36  
         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)

Thanks for looking into this!

ljharb

ljharb commented on Sep 26, 2016

@ljharb
Member

@peteringraham hm, it's possible that v5.7.1 is corrupted? could you try nvm uninstall v5.7.1 && nvm install v5.7.1 and see if the issue is fixed?

peteringraham

peteringraham commented on Sep 27, 2016

@peteringraham
Author

Looks like it worked. I guess this was a side-effect of sudo npm install -g when trying to fix unrelated errors earlier.

nvm uninstall 5.7.1
file is not writable: $NVM_DIR/versions/node/v5.7.1/bin/grunt
Cannot uninstall, incorrect permissions on installation folder.
This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again.

  chown -R pingraham "$NVM_DIR/versions/node/v5.7.1"
  chmod -R u+w "$NVM_DIR/versions/node/v5.7.1"

After running those, uninstalling, and reinstalling, no error message, node -v returns 5.7.1.

I'll re-open if something surprising happens later, but I think this is mostly fixed.

Note that nvm ls now claims it's using "5.7.1" rather than "system", so maybe using the system version of node isn't really supported? OTOH, this might be too specific & weird a situation to bother having specific commentary on.

Thanks again for your help.

elimcjah

elimcjah commented on Aug 31, 2017

@elimcjah

@ljharb Thanks! nvm uninstall v5.7.1 && nvm install v5.7.1 worked for me.

jedwards1211

jedwards1211 commented on Dec 12, 2017

@jedwards1211

None of the fixes here seem to have worked for me, and I get this error regardless of which version I'm trying to switch to.

However, if I merely run nvm use a second time, it succeeds. I wonder if that's why some of these fixes "worked" for other folks here? If I open a new terminal I get the error again the first time I run nvm use, and after that it's okay.

68 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS: Mac OSbugsOh no, something's broken :-(needs followupWe need some info or action from whoever filed this issue/PR.shell: bash/sh

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@radum@jamesdixon@travi@giedriusr

        Issue actions

          NVM is not compatible with the npm config "prefix" option warning (OS X) · Issue #1245 · nvm-sh/nvm