wbyoung / avn

Automatic Version Switching for Node
MIT License
1.14k stars 54 forks source link

parse error / avn could not activate node / avn could not activate node v4.0 #82

Closed hubitor closed 5 years ago

hubitor commented 5 years ago

I just installed avn with:

$ sudo npm install -g avn avn-nvm avn-n
$ avn setup

After that I did:

source ~/.zshrc

and I got an error like this (I didn't copy it...):

parse error in line 134 of ~/.avn/bin/anv.sh

Then I restarted my system and did a __avn_debug with this output:

avn could not activate node v8.12.0
error: no plugin passed predicate
  avn-nvm: nvm exited with status: 127
zsh:source:1: no such file or directory: /home/user/.nvm/nvm.sh
zsh:1: command not found: nvm
  avn-n: no version matching v8.12.0

Indeed there wasn't such file. I found this line in the file: ~/.avn/plugins/avn-nvm/index.js

['-c', 'source $NVM_DIR/nvm.sh; nvm ' + command]);

which I changed to:

['-c', 'source /usr/share/nvm/init-nvm.sh; nvm ' + command]);

(I'm using Arch Linux based distro and I have installed nvm from the AUR)

Now __avn_debug gives me:

avn activated v8.12.0 (avn-nvm v8.12.0)
nvm use v8.12.0 > /dev/null;

After this change avn seems to be working.

Besides that when I change into this folder: /home/user/.avn I get this message:

avn could not activate node v4.0

I don't understand why I'm getting this message in this folder. I have only installed v8.12.0 with nvm:

$ nvm ls
->      v8.12.0
         system
node -> stable (-> v8.12.0) (default)
stable -> 8.12 (-> v8.12.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.12.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.4 (-> N/A)
lts/carbon -> v8.12.0

Details

The output of __avn_debug in the directory with a .node-version file is: See above

avn is loaded in my ~/.{bash|zsh}{_profile|rc} file with:

[[ -s "$HOME/.avn/bin/avn.sh" ]] && source "$HOME/.avn/bin/avn.sh" # load avn

nvm specific

ljharb commented 5 years ago

That’s because you didn’t install nvm separately. The nvm-init thing you mentioned, i have no idea what that is.

hubitor commented 5 years ago

Like I mentioned, I've installed the nvm package from the AUR (https://aur.archlinux.org/packages/nvm/ and this includes a script: /usr/share/nvm/init-nvm.sh. with this content:

[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
source /usr/share/nvm/nvm.sh
source /usr/share/nvm/bash_completion
source /usr/share/nvm/install-nvm-exec

avn works fine for me now. I just opened the issue in case the developers see something strange and want to improve or someone else encounters this issue and might find this info useful.

wbyoung commented 5 years ago

There's no issue here — installing nvm is documented to only be acceptable in one way. The fact that there's a .node-version file in the .avn directory is technically unnecessary. I don't recall writing code to have that added there, but I have one on my machine, too. It won't affect how anything operates, though. It just suggests that you should develop avn with that version of Node.js.