Sitelet https://web.archive.org/web/20200910094713/https://github.com/nvm-sh/nvm/issues/2088
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No npm prefix set, but nvm requires 'nvm use --delete-prefix' #2088

Open
pklapperich opened this issue Aug 13, 2019 · 11 comments
Open

No npm prefix set, but nvm requires 'nvm use --delete-prefix' #2088

pklapperich opened this issue Aug 13, 2019 · 11 comments

Comments

@pklapperich
Copy link

@pklapperich pklapperich commented Aug 13, 2019 •

  • Operating system and version:
$ lsb_release -a
LSB Version:	1.4
Distributor ID:	Arch
Description:	Arch Linux
Release:	rolling
Codename:	n/a
  • nvm debug output:
$ nvm debug
nvm --version: v0.34.0
$SHELL: /bin/bash
$SHLVL: 2
$HOME: /home/paulk/
$NVM_DIR: '$HOME/.nvm'
$PATH: /usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/platform-tools:/usr/lib/jvm/default/bin:/usr/lib32/jvm/default/bin:/opt/ti/msp-flasher:/opt/ti/mspgcc/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$HOME/bin/:$HOME.gem/ruby/2.3.0/bin:/opt/android-sdk/platform-tools/:$HOME.bin:$HOMEbin/gyb:
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.0.7(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.1.15-zen1-1-zen #1 ZEN SMP PREEMPT Tue Jun 25 04:49:28 UTC 2019 x86_64 GNU/Linux'
OS version: Arch Linux  ()
curl: /usr/bin/curl, curl 7.65.3 (x86_64-pc-linux-gnu) libcurl/7.65.3 OpenSSL/1.1.1c zlib/1.2.11 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.8.2 nghttp2/1.36.0
wget: /usr/bin/wget, GNU Wget 1.20.3 built on linux-gnu.
git: /usr/bin/git, git version 2.22.0
grep: /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.3
awk: /usr/bin/awk, GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
sed: /usr/bin/sed, sed (GNU sed) 4.7
cut: /usr/bin/cut, cut (GNU coreutils) 8.31
basename: /usr/bin/basename, basename (GNU coreutils) 8.31
rm: /usr/bin/rm, rm (GNU coreutils) 8.31
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.31
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.6.0
nvm current: system
which node: /usr/bin/node
which iojs: which: no iojs in (/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/platform-tools:/usr/lib/jvm/default/bin:/usr/lib32/jvm/default/bin:/opt/ti/msp-flasher:/opt/ti/mspgcc/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$HOME/bin/:$HOME.gem/ruby/2.3.0/bin:/opt/android-sdk/platform-tools/:$HOME.bin:$HOMEbin/gyb:)
which npm: /usr/bin/npm
npm config get prefix: /usr
npm root -g: /usr/lib/node_modules
  • nvm ls output:
$ nvm ls
        v8.16.0
       v10.16.2
->       system
node -> stable (-> v10.16.2) (default)
stable -> 10.16 (-> v10.16.2) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/dubnium (-> v10.16.2)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.0
lts/dubnium -> v10.16.2

</details>

- How did you install `nvm`? (e.g. install script in readme, Homebrew):
nvm installed from https://aur.archlinux.org/packages/nvm/
My ~/.bashrc ends with:
<details>

  <!-- do not delete the following blank line -->

```sh
export PATH="$PATH:$(yarn global bin)"
export NVM_DIR="$HOME/.nvm"
source /usr/share/nvm/init-nvm.sh
  • What steps did you perform?
    Anytime I run nvm use {NODE_VERSION} it complains
nvm is not compatible with the npm config "prefix" option: currently set to "/home/paulk/.nvm/versions/node/v{NODE_VERSION}"
Run `npm config delete prefix` or `nvm use --delete-prefix v{NODE_VERSION}` to unset it.

If I set a default alias, then the error message appears anytime I open a shell. NVM seems to work just fine if I use nvm use --delete-prefix every time I try to load a different NVM version.

  • What did you expect to happen?
    I expected nvm to silently switch to the specified node. I'd like to be able to set a default prefix.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
    Yes, but it's all before the lines that load nvm.

My ~/.npmrc contains only the local-address=10.1.2.123 option.

@ljharb

This comment was marked as outdated.

@pklapperich

This comment was marked as outdated.

@ljharb

This comment was marked as outdated.

@pklapperich
Copy link
Author

@pklapperich pklapperich commented Aug 13, 2019

Looks like it's caused by the extra / in $NVM_DIR.

$ nvm use lts/carbon
nvm is not compatible with the npm config "prefix" option: currently set to "/home/paulk/.nvm/versions/node/v8.16.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.16.0` to unset it.
$ nvm use lts/carbon
nvm is not compatible with the npm config "prefix" option: currently set to "/home/paulk/.nvm/versions/node/v8.16.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.16.0` to unset it.
$ export NVM_DIR=/home/paulk/.nvm
$ nvm use lts/carbon
Now using node v8.16.0 (npm v6.4.1)
@ljharb
Copy link
Member

@ljharb ljharb commented Aug 13, 2019

aha, yes. does $HOME have an extra slash in it?

@ljharb
Copy link
Member

@ljharb ljharb commented Aug 13, 2019

I see that it does. $HOME is a directory path, and the trailing slash means “inside the dir”. If you fix that in your profile files, you should be fine.

@MRigal
Copy link

@MRigal MRigal commented Aug 13, 2019

Funny, I had and could fix exactly the same problem this way this morning! Remove the trailing slash in $HOME https://serverfault.com/questions/876317/what-to-do-with-trailing-slash-in-home-on-centos

@pklapperich
Copy link
Author

@pklapperich pklapperich commented Aug 13, 2019 •

I have other things that expect the trailing slash in the $HOME, so I fixed it when declaring $NPM_HOME instead.

I would still consider this a bug and encourage you to fix whatever is parsing this. In shell, a path of /////usr/var/./././././////././././//log/ is valid and collapses to /usr/var/log. I know some languages have libraries that will normalize paths for you (os.path.abspath() in python for example).

@ljharb
Copy link
Member

@ljharb ljharb commented Aug 13, 2019 •

Those other things are incorrect; a trailing slash makes it not a directory.

That said, #1708 / #1734 fixed this for NVM_DIR; it seems reasonable to fix broken $HOME vars as well.

@radum
Copy link

@radum radum commented Aug 22, 2019

For those coming here and you are using a Mac, my issue was that my user folder had upper case letters in it, but my profile folder setting under users pointed to the all lower case path version of it. Once I logged in from another account renamed to have all lower case all worked just fine.

@kuncevic
Copy link

@kuncevic kuncevic commented Nov 29, 2019 •

Just updated to Catalina (10.15.1) and had same issue
Deleting /usr/local/bin/npm solved my issue
And then I had to reinstall node as npm just stopped working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.