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

Manjaro: nvm is not compatible with the npm config "prefix" option: currently set to "" #1968

Closed
Jan-Jan opened this issue Dec 27, 2018 · 66 comments
Labels
installing node Issues with installing node/io.js versions. OS: manjaro

Comments

@Jan-Jan
Copy link

Jan-Jan commented Dec 27, 2018

All of a sudden nvm stopped working :-( I've done a clean install of nvm. It goes well. Then when I do nvm install lts/dubnium I get the following error.

nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.15.0` to unset it.

Since, lts/dubnium was successfully installed, I also tried nvm use lts/dubnium I get the same error.

If I run nvm use --delete-prefix v10.15.0, then the system node get used, and I cannot get it to use lts/dubnium.

There is no .npmrc file. I use zsh.

  • Operating system and version: 4.19.12-2-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux

  • nvm debug output:

nvm --version: v0.33.11
$SHELL: /bin/zsh
$SHLVL: 1
$HOME: /home/naturgewalt
$NVM_DIR: '$HOME/.nvm'
$PATH: /usr/local/bin:/usr/local/sbin:/usr/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/cuda/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:$HOME/.gem/ruby/2.5.0/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.6.2 (x86_64-pc-linux-gnu)'
uname -a: 'Linux 4.19.12-2-MANJARO #1 SMP PREEMPT Sun Dec 23 19:08:00 UTC 2018 x86_64 GNU/Linux'
OS version: Manjaro Linux   () ()
curl: /usr/bin/curl, curl 7.62.0 (x86_64-pc-linux-gnu) libcurl/7.62.0 OpenSSL/1.1.1a zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.4) libssh2/1.8.0 nghttp2/1.34.0
wget: /usr/bin/wget, GNU Wget 1.19.5 built on linux-gnu.
git: /usr/bin/git, git version 2.19.2
grep: grep: aliased to grep --color=auto (grep --color=auto), grep (GNU grep) 3.1
awk: /usr/bin/awk, GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
sed: /usr/bin/sed, sed (GNU sed) 4.5
cut: /usr/bin/cut, cut (GNU coreutils) 8.30
basename: /usr/bin/basename, basename (GNU coreutils) 8.30
rm: /usr/bin/rm, rm (GNU coreutils) 8.30
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.30
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.6.0
nvm current: system
which node: /usr/bin/node
which iojs: iojs not found
which npm: /usr/bin/npm
npm config get prefix: /usr
npm root -g: /usr/lib/node_modules
  • nvm ls output:
       v10.15.0
->       system
default -> lts/dubnium (-> v10.15.0)
node -> stable (-> v10.15.0) (default)
stable -> 10.15 (-> v10.15.0) (default)
iojs -> N/A (default)
lts/* -> lts/dubnium (-> v10.15.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.16.0 (-> N/A)
lts/carbon -> v8.15.0 (-> N/A)
lts/dubnium -> v10.15.0
  • How did you install nvm? (e.g. install script in readme, Homebrew):

  • What steps did you perform? What happened?

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

which worked great.

Then I ran nvm install lts/dubnium resulting in

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12819  100 12819    0     0   1347      0  0:00:09  0:00:09 --:--:--  2268
=> Downloading nvm from git to '/home/naturgewalt/.nvm'
=> Cloning into '/home/naturgewalt/.nvm'...
remote: Enumerating objects: 267, done.
remote: Counting objects: 100% (267/267), done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 267 (delta 31), reused 86 (delta 15), pack-reused 0
Receiving objects: 100% (267/267), 119.47 KiB | 26.00 KiB/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository

=> nvm source string already in /home/naturgewalt/.zshrc
=> bash_completion source string already in /home/naturgewalt/.zshrc
npm ERR! missing: semver@~5.3.0, required by node-gyp@3.8.0
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:

/usr/lib
├── atom-package-manager@2.1.3
├── emojione@4.0.0
└── yarn@1.12.3
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:

     $ nvm use system
     $ npm uninstall -g a_module

=> Close and reopen your terminal to start using nvm or run the following to use it now:

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

which installed the v10.15.0, but gave the error

nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.15.0` to unset it.
@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 27, 2018

I tried the following workaround (in .zshrc):

export NVM_DIR=~/.nvm
source "$NVM_DIR/nvm.sh"
export PATH=$NVM_DIR/versions/node/v10.14.0/bin:$PATH

Which does result in the correct which node or which npm, but if I try node I get segmentation fault (core dumped) node

@ljharb
Copy link
Member

ljharb commented Dec 27, 2018

ok, so first, you def don’t need to manually overwrite the path.

as for the segmentation fault; what is manjaro? is there a chance that it’s 32-bit, which means node 10+ might not work on it? Does node 8 or 9 work?

@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 27, 2018

it is 64 bit, and till the latest version everything worked.
there is a system node installed under /usr/bin/node and that works fine
if I don't override the $PATH, then ~/.nvm/versions/node/v10.14.0/bin/node also works fine, just that nvm doesn't

@ljharb
Copy link
Member

ljharb commented Dec 27, 2018

OK - so you're saying that ~/.nvm/versions/node/v10.14.0/bin/node --version works, but when which node prints out that identical path, node --version does not?

@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 28, 2018

  • ~/.nvm/versions/node/v10.14.0/bin/node --version works
  • however which node prints out /usr/bin/node, and nvm is incapable of changing that
  • (node --version also works, and it gives the version as per /usr/bin/node)

@ljharb
Copy link
Member

ljharb commented Dec 28, 2018

OK, so, let's see.

What's the output of the following?

echo $PATH
nvm use node --delete-prefix
echo $PATH

@davidgf
Copy link

davidgf commented Dec 28, 2018

I'm getting the same behavior as @Jan-Jan, with exactly the same OS version. However, if I switch to node v8.15.0 everything seems to work fine

@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 28, 2018

/usr/local/bin:/usr/local/sbin:/usr/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/cuda/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

and

/home/naturgewalt/.nvm/versions/node/v10.14.0/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/cuda/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

however, if I run node after the second command I get seg fault

@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 28, 2018

I could replicate the behaviour @davidgf saw:
nvm works 100% with node v8.15.0, but fails with v10.* and v11.6.0

@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 28, 2018

I've tried building from source the problem remains exactly the same

@ljharb
Copy link
Member

ljharb commented Dec 28, 2018

My hunch is that there’s something in your PATH that’s a shared library, that works with your system node (and node 8) but makes node 10+ crash - i assume of you upgraded your system node to 10 or 11, either 1) it’d fix nvm for node 10+ but break it for < 10; or 2) your system node would start crashing in the same way.

I’m not sure how to debug it; but it might be worth filing an issue on node itself - when which node points to an nvm-installed node, at that point nvm has done its job :-/

Let’s keep this open in case more ideas surface about a direction.

@Jan-Jan
Copy link
Author

Jan-Jan commented Dec 28, 2018

My system node is node 11. nvm on node 11 does not work

@ljharb
Copy link
Member

ljharb commented Dec 28, 2018

Hmm, that's very strange. Still, the segmentation fault seems to be an issue with node, specifically - I'd still suspect that uninstalling your system node might fix the problem.

@myf
Copy link

myf commented Dec 30, 2018

i am noticing the same behavior on archlinux. `signal1 fails to build because of this nvm issue
at https://aur.archlinux.org/packages/signal/

==> Starting build()...
v10.13.0 is already installed.
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.13.0` to unset it.
Found '/tmp/yaourt-tmp-user/aur-signal/src/signal-git-repo/.nvmrc' with version <10.13.0>
v10.13.0 is already installed.
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.13.0` to unset it.
Found '/tmp/yaourt-tmp-user/aur-signal/src/signal-git-repo/.nvmrc' with version <10.13.0>
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.13.0` to unset it.

@myf
Copy link

myf commented Dec 30, 2018

ok i did some digging around but because i am really not familar with the codebase itself i think someone might be better equipped at fixing this than me.
the problem seems to be that line 2177 at nvm.sh https://github.com/creationix/nvm/blob/master/nvm.sh#L2177 cannot be executed correctly. $(npm config get prefix) returns nothing, and actually $(npm ANYTHING) will return nothing. just to test myself not going crazy i swapped it with $(date) or $(python SOMETHING) which both worked. there might be some phrase in this gigantic file that bars node or npm from executing and if prefix is derived from npm then this won't work. i think it's a simple fix though but i am unable to correctly identify what caused it..

@ljharb
Copy link
Member

ljharb commented Dec 30, 2018

npm config get prefix should definitely return something on that line; at the point where that "returns nothing" for you, what does type npm and which npm print out?

@myf
Copy link

myf commented Dec 30, 2018

which npm give me /home/myf/.nvm/versions/node/v10.13.0/bin/npm
ahh now i remember when i tried to use this version by nvm --delete-prefix use v10.13.0 i got coredump. maybe that's the reason of no return??

@ljharb
Copy link
Member

ljharb commented Dec 30, 2018

@myf certainly if node and npm won't both compile and execute properly, such that you get a core dump, then there's not much nvm can do :-/

@myf
Copy link

myf commented Dec 30, 2018

@ljharb i just tried to run node and npm directly from .nvm/versions/node/v10.13.0/bin/ it works correctly

@ljharb
Copy link
Member

ljharb commented Dec 30, 2018

That is baffling! Why would invoking it directly work, but PATH=".nvm/versions/node/v10.13.0/bin/:$PATH" node fail? Does PATH=".nvm/versions/node/v10.13.0/bin/" node also fail?

@myf
Copy link

myf commented Dec 30, 2018

@ljharb

[1]    11838 segmentation fault (core dumped)  PATH=".nvm/versions/node/v10.13.0/bin/:$PATH" node
➜  ~ PATH=".nvm/versions/node/v10.13.0/bin/" node 
[1]    11862 segmentation fault (core dumped)  PATH=".nvm/versions/node/v10.13.0/bin/" node

@ljharb
Copy link
Member

ljharb commented Dec 30, 2018

yet .nvm/versions/node/v10.13.0/bin/node sends you into the repl?

@ljharb
Copy link
Member

ljharb commented Dec 30, 2018

if so, this really seems like something you'd need to file on node itself.

@myf
Copy link

myf commented Dec 30, 2018

@ljharb yup that is the behavior! from that signal aur error posted above i think i am not alone in this. we are using node@11.6.0 at the moment

@ljharb
Copy link
Member

ljharb commented Dec 30, 2018

Given that everyone with this issue is on "manjaro" I still am inclined to believe it's an issue with node itself, not nvm.

@myf
Copy link

myf commented Dec 30, 2018

@ljharb one sec, i think v10.13.0 is the one that is affected. v8.9.3 worked fine on my system
PATH=".nvm/versions/node/v8.9.3/bin/" node would drop me in the repl

@barraponto
Copy link

I'm having the same message printed on Archlinux (Manjaro is based on it).
But I get no segfault.

@CrowderSoup
Copy link

I'm having this issue as well, on OSX Mojave with node v10.15.0

@ljharb
Copy link
Member

ljharb commented Jan 2, 2019

@CrowderSoup everyone else seems to be using Arch or Manjaro; you're the first that's using OS X. Can you provide your nvm debug output? If you have a system node, how did you install it and what version is it? If you try the steps here, what happens?

@santiini
Copy link

santiini commented Jan 8, 2019

I resolve it with this issuse

@ljharb
Copy link
Member

ljharb commented Jan 8, 2019

v0.34.0 is released; can all of you try updating and see if the problem is still there? I don't expect it'll fix things, but it's worth a shot.

@myf
Copy link

myf commented Jan 9, 2019

@ljharb tested, same issue with v10.x node branches

@AdrienLemaire
Copy link

@ljharb if you can check out this related issue: lukechilds/zsh-nvm#52. I had the same problem whether I tried archlinux's nvm package or zgen's zsh-nvm package.
Wondering why /usr/bin/env seemingly causes so many problems ^^

@ljharb
Copy link
Member

ljharb commented Jan 17, 2019

Considering it's a best practice to always filter everything through /usr/bin/env, i'm not really sure what to do there :-/

@cryptosalomao
Copy link

I'm getting a segfault when trying to use npm after changing my node version through nvm. It returns me:

nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.10.0` to unset it.

Currently i'm using Arch Linux too.

@DimitrK
Copy link

DimitrK commented Apr 1, 2019

Same issue here as well on Manjaro with nvm 0.34. Can use previous LTS versions just fine but not dubnium

@knshetty
Copy link

knshetty commented Apr 6, 2019

I'm also able to reproduce this issue on my Manjaro Linux running nvm version: 0.34.0.
Following versions of node works:

  • v8.15.1(Latest LTS: Carbon) until v9.11.2
  • v11.7.0 until v11.13.0

However, nvm fails to switch over to following versions of node:

  • v10.0.0 until v11.6.0

@ljharb
Copy link
Member

ljharb commented Apr 6, 2019

This then seems like an issue with node itself, and its compatibility with Manjaro - and not something nvm can fix. Has an issue been filed on node?

@DimitrK
Copy link

DimitrK commented Apr 6, 2019

I am having same issue on one of my OSX machines at work. Installing node v11 standalone works though.

@ljharb
Copy link
Member

ljharb commented Apr 6, 2019

@DimitrK can you file a separate issue about your OS X problem? There's a few comments on this issue unrelated to manjaro but it'd be great if you could file something separate (@CrowderSoup figured out their problem, and it was unrelated)

@srgl
Copy link

srgl commented Apr 16, 2019

nvm 0.34, fresh manjaro, oh-my-zsh, facing the same issue while trying to switch to node 10:
8.15.1 - works
9.11.2 - works
10.15.3 - doesn't work
11.14.0 - works

@mikeehun
Copy link

mikeehun commented Apr 18, 2019

For the time being, after trying out many things suggested, I think the easiest solution on manjaro/zsh to just install the version in the repo, which works fine if you only need 10.15.3 node:

sudo pacman -S nodejs-lts-dubnium npm

@ljharb
Copy link
Member

ljharb commented Apr 18, 2019

This clearly seems to be an issue with node 10 and Manjaro.

If there ends up being a simple workaround nvm can detect and apply to make it work, I’ll happily reopen this and add it.

Otherwise, please file an issue on one or both of node or manjaro, since it’s a bug with one of them (probably not node).

@ljharb ljharb closed this as completed Apr 18, 2019
@ljharb ljharb added installing node Issues with installing node/io.js versions. OS: manjaro labels Apr 18, 2019
@agaskell
Copy link

I figured this out on my system. For other Arch/Manjaro users here's how you can find the cause:

  • Install the crashing version of node with nvm.
  • Add the crashing version to your path so when you run node it executes:
    export PATH="/home/foo/.nvm/versions/node/v10.15.3/bin:$PATH"
  • Run node, have it segfault.
  • Run coredumpctl gdb -1. You'll see information from the core dump. At the very bottom you will likely see a .so file referenced, here's mine:

#0 0x00007fea7b0f114d in v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int, v8::ConstructorBehavior) () from /usr/lib/popcorntime/0.3.10/libnw.so

So for me it was Popcorn Time installed from the AUR (popcorntime-bin). After I removed Popcorn Time all versions of node worked.

@smac89
Copy link

smac89 commented Apr 27, 2019

@agaskell Good eye

I'm on arcolinux here and my output definitely points to libnw.so, but says nothing about where it is from (i.e. popcorntime), however I did have popcorntime-bin installed. After removing popcorntime, I didn't even have to close my terminal; but instead ran node again and it worked!

Thank you!

EDIT:
I have installed this popcorntime (https://aur.archlinux.org/packages/popcorntime-git/) and it works with NVM. It does take a bit to download, compile and install (about 4 mins for me).

@dberruezo
Copy link

dberruezo commented May 6, 2019

I'm having the same issue but with Kubuntu. As said here: #1968 (comment), the same versions give me the "prefix" error and "npm" fails to execute. The only difference is that I don't get a segfault but "zsh: command not found: npm" message.

I got a segfault once but can't seem to reproduce it and afterwards "node" and "npm" run just fine if executed from ".nvm" folder, "npm" does not work at all. both "node" and "npm" are not found when trying to change to v10.x branches.

@dagadbm
Copy link

dagadbm commented May 8, 2019

just changing the nvm_dir script code on my zshrc fixed it:

  export NVM_DIR="$(realpath ~/.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

@ljharb
Copy link
Member

ljharb commented May 8, 2019

@dagadbm that’s because nvm doesn’t work if NVM_DIR or HOME are symlinks. See #617.

@dagadbm
Copy link

dagadbm commented May 8, 2019

yh I know. I thought this might be related. or someone else might come in here and try and look for answers as I did.
My case was because I was using WSL (wsl even does some crazy permissions on the sym linked folders that made zsh complain lol).

@mikelane
Copy link

just changing the nvm_dir script code on my zshrc fixed it:

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

This is what fixed me. My work system has my home directory symlinked to a different volume.

@ljharb
Copy link
Member

ljharb commented Jul 13, 2020

@mikelane see #617.

@Devendrateja

This comment has been minimized.

@ljharb

This comment has been minimized.

@dagadbm

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing node Issues with installing node/io.js versions. OS: manjaro
Projects
None yet
Development

No branches or pull requests