wbyoung / avn

Automatic Version Switching for Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

hubitor opened this issue · comments

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

  • avn avn --version
    0.2.3
  • node node --version
    v10.12.0
  • nvm nvm --version
  • n n --version
    0.33.11
  • zsh zsh --version
    zsh 5.6.2 (x86_64-pc-linux-gnu)
  • bash bash --version
    GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)

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

  • As an nvm user I am confirming that I did not install with Homebrew

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

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.

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.