Nvm: Your user’s .npmrc file (${HOME}/.npmrc) has a `globalconfig` and/or a `prefix` setting, which are incompatible with nvm.

Created on 8 Nov 2020  Â·  12Comments  Â·  Source: nvm-sh/nvm

Operating system and version:

nvm debug output:


nvm --version: v0.37.0
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'dougouverson'
${HOME}: /Users/dougouverson
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v15.1.0/bin:./node_modules/.bin:${HOME}/.npm/bin:${HOME}/.pyenv/plugins/pyenv-virtualenv/shims:${HOME}/.pyenv/shims:${HOME}/.pyenv/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:${HOME}/Dropbox/learning/nand2tetris/tools
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64'
checksum binary: 'shasum'
OS version: Mac 10.15.7 19H15
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: rm: aliased to rm -rf (rm -rf)
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.29.2
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: v15.1.0
which node: ${NVM_DIR}/versions/node/v15.1.0/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v15.1.0/bin/npm
npm config get prefix: ${HOME}/.npm
npm root -g: ${HOME}/.npm/lib/node_modules

nvm ls output:


->      v15.1.0
         system
default -> node (-> v15.1.0)
node -> stable (-> v15.1.0) (default)
stable -> 15.1 (-> v15.1.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/fermium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.0 (-> N/A)
lts/erbium -> v12.19.0 (-> N/A)
lts/fermium -> v14.15.0 (-> N/A)

How did you install nvm?


curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash

What steps did you perform?

Ran commands to install and use node
nvm install node
nvm use node

What happened?

It seems that nvm did in fact install v15.1.0 but I'm also getting this error message every time I open a new terminal window:

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

What did you expect to happen?

Not to get an error message.

I did run nvm use --delete-prefix v15.1.0 --silent but this did not fix.

I did shut down iTerm and restarted - only to get error message.

One thing I did notice: I opened .npmrc and see there is one line:

prefix=/Users/dougouverson/.npm

Just to see what would happen, I deleted this line > saved file > exited and opened iTerm. No change.

Is there anything in any of your profile files that modifies the PATH?

Not that I'm aware of. zsh is now the default shell on macOS 10.15.7

non-issue / invalid

All 12 comments

Deleting that line in .npmrc should indeed have fixed it (it shouldn't be there at all).

You're saying that nvm use --delete-prefix v15.1.0 still doesn't work after that? What code does it exit with (echo $?)?

Also, what does npm config get prefix and which node print out when you're using your system node?

$ nvm use --delete-prefix v15.1.0 --silent
$ echo $?
0

$ npm config get prefix
/Users/dougouverson/.nvm/versions/node/v15.1.0

$ cat .npmrc
prefix=/Users/dougouverson/.npm

How can I figure out what program/script keeps writing to .npmrc?

I’m afraid that’s something i cant help you with :-/ you might have a npm config set prefix command somewhere, or just be appending to the file directly.

You could try changing the permissions on npmrc so nothing can write to it, and see what errors?

I’m going to close this for now, since the issue isn’t with nvm, just with whatever’s setting your “prefix” setting.

This is disappointing. Where am I to go to get help fixing an NVM issue if not in the NVM issue desk?

You say the issue isn't with NVM, and that may be the case. But, this is the second time I've had this issue with getting Node environment set up on macOS, and the only thing in common was NVM.

What else could it be?

Or maybe you could point me in a direction where I could get help.

Thanks so much.

And I don't think my issue was "invalid" - humbly!

Sorry if I was unclear :-) I'm happy to keep trying to help! However, i don't think there's anything i can fix in nvm about it, since nvm is incompatible with the "prefix" setting.

As for "invalid", you're right, that's probably not the best label name - it just means "not a problem with nvm". I'll rename the label slightly.

Can you share the content of your profile files? (with any sensitive info redacted)

Can you share the contents of .zprofile and .zshrc?

Everything seems to working fine now.

I was able to remove the .npmrc and nothing is writing it again. I'm not sure what script/program created .npmrc in the first place?

Question:

I noticed that when I quit and restart terminal that node version reverts to default (in my case v12.19.0)

Is this normal behavior?

Glad to hear it!

Yes, that’s expected. You can change the default with nvm alias default, or remove it with nvm unalias default.

Thanks so much for hanging in there with me!

Was this page helpful?
0 / 5 - 0 ratings